Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Apr 13 14:52

    elevans on master

    Add combine channels snippet A… (compare)

  • Apr 09 18:37
    chaichontat commented #22
  • Apr 05 18:37

    elevans on master

    Fix typos and styling (compare)

  • Apr 05 18:10

    elevans on master

    Add methods for opening images … Add sample files for code snipp… (compare)

  • Apr 05 13:09

    elevans on master

    Add notebook with useful PyImag… (compare)

  • Apr 03 20:46
    imagejan commented #111
  • Apr 03 20:45
    imagejan commented #112
  • Apr 03 09:32
    egonw opened #25
  • Apr 03 06:19
    lollows closed #111
  • Apr 03 06:19
    lollows commented #111
  • Apr 03 06:11
    lollows opened #112
  • Apr 03 06:08
    lollows opened #111
  • Apr 03 02:33
    ddddg929 closed #109
  • Apr 03 02:33
    ddddg929 commented #109
  • Apr 02 13:27
    imagejan opened #110
  • Apr 02 13:27

    imagejan on forum-badge

    README: add forum badge (compare)

  • Apr 02 13:19
    imagejan commented #109
  • Apr 02 12:33
    ddddg929 commented #109
  • Apr 02 12:28
    ddddg929 commented #109
  • Apr 02 12:23
    ddddg929 edited #109
Jan Eglinger
@imagejan
(Likely you know all this already, sorry if I’m telling obvious things)
Edward Evans
@elevans

@hinerm heads up...I'm in the middle of answering a question on image.sc for pyimagej that ani submitted. When I slice the xarray and remove channels I can write the file out just fine. If I slice the xarray and remove time points and write the file out its unreadable by fiji:

(Fiji Is Just) ImageJ 2.1.0/1.53c; Java 1.8.0_172 [64-bit]; Linux 5.8.0-41-generic; 412MB of 18819MB (2%)

java.lang.IllegalArgumentException: Unknown stack type
    at ij.ImageStack.getProcessor(ImageStack.java:289)
    at ij.ImagePlus.setStack(ImagePlus.java:742)
    at ij.ImagePlus.<init>(ImagePlus.java:158)
    at ij.io.Opener.openTiffStack(Opener.java:809)
    at ij.io.Opener.openTiff2(Opener.java:1034)
    at ij.io.Opener.openTiff(Opener.java:842)
    at ij.io.Opener.openImage(Opener.java:317)
    at ij.io.Opener.openImage(Opener.java:243)
    at ij.io.Opener.open(Opener.java:109)
    at ij.io.Opener.openAndAddToRecent(Opener.java:292)
    at ij.plugin.DragAndDrop.openFile(DragAndDrop.java:194)
    at ij.plugin.DragAndDrop.run(DragAndDrop.java:160)
    at java.lang.Thread.run(Thread.java:748)

I'm going to look at the xarray object that i'm working with and see if I'm doing anything obviously stupid...but do you have any quick ideas while i investigate?

Here's what i'm donig:
import imagej
import numpy as np

# start pyimagej
ij = imagej.init('sc.fiji:fiji')
ij.getVersion()

# load test image
ij_img = ij.io().open('test.tif')
py_img = ij.py.from_java(ij_img)

# delete the first 4 frames
delFront = py_img[4:, :, :, :]

# write file
img_out = ij.py.to_java(delFront)
output_file = 'test_output.tif'
ij.io().save(img_out, output_file)
its pretty simple
Mark Hiner
@hinerm
@elevans I don't know what could be going on, offhand. Did you try the np.delete methods first to see if they were working as intended?
my thinking was that her problem is in newImg = delFront - delEnd #subtract the two images from each other?
as I think that has like.. no chance of doing what she wanted?
I think there's an ops.subtract op that would work though?
Edward Evans
@elevans
yeah i don't thinks going to work. I know what she wants to do and the ImageCalculator is what they normally use
But she wanted to try using just numpy which I figured should be totally possible. I didn't even get far enough to try using ops.subtract. just removing time points from 3D data breaks the .tif apparently. I'm going to try np.delete
np.delete breaks the .tif output as well
brb going into the xarray docs. time for some more coffee
Curtis Rueden
@ctrueden
Why wouldn't that subtraction work? Python supports that sort of operator overloading, right? So as long as those are Python images, and not Java images...?
Some day, it will be great to hook up ops to those.
Let me know if you need my eyes on that question, guys. Otherwise, my day today is focused on the jgo PR and the new ImageJ website.
Mark Hiner
@hinerm
hm I didn't realize python had implemented image subtraction. that's cool. yeah seems like it should work
Curtis Rueden
@ctrueden
@hinerm I'm not totally certain... but it's possible. I'll test it quick.
Mark Hiner
@hinerm
stackoverflow says yes
Curtis Rueden
@ctrueden
That's an OpenCV Python image though...
I assume it'll work with numpy images too, but checking just to be sure.
Curtis Rueden
@ctrueden
>>> img
array([[ 47, 123, 133, ...,  14,   3,  12],
       [ 93, 144, 145, ...,  12,   7,   7],
       [126, 147, 143, ...,   2,  13,   3],
       ...,
       [ 81,  79,  74, ...,   6,   4,   7],
       [ 88,  82,  74, ...,   5,   7,   8],
       [ 91,  79,  68, ...,   4,  10,   7]], dtype=uint8)
>>> noise
array([[ 20, 141, 206, ..., 154, 225,  41],
       [227, 141, 127, ..., 180, 148,   1],
       [163,  98, 108, ..., 226, 106, 239],
       ...,
       [ 86, 136,  25, ..., 104,  69, 125],
       [ 18, 102,  78, ..., 101, 234,  93],
       [139,  97,  56, ...,  87, 195, 158]], dtype=uint8)
>>> img - noise
array([[ 27, 238, 183, ..., 116,  34, 227],
       [122,   3,  18, ...,  88, 115,   6],
       [219,  49,  35, ...,  32, 163,  20],
       ...,
       [251, 199,  49, ..., 158, 191, 138],
       [ 70, 236, 252, ..., 160,  29, 171],
       [208, 238,  12, ..., 173,  71, 105]], dtype=uint8)
:+1:
And here's how I created the images, if you're curious:
import numpy
import skimage
img = skimage.data.coins()
noise = numpy.zeros(img.shape, img.dtype)
from random import random
for y in range(noise.shape[0]):
  for x in range(noise.shape[1]):
    noise[y,x] = int(255 * random())
(I don't know a slicker way to iterate a numpy image while mutating it... does anyone else?)
Edward Evans
@elevans
@ctrueden Cool I had no idea python had image subtraction!
Jan Eglinger
@imagejan
:laughing: there’s a reason why people love python for image processing these days.
Jan Eglinger
@imagejan
@ctrueden in this case, how about:
noise = numpy.random.rand(*img.shape) * 255
Curtis Rueden
@ctrueden
@imagejan Huh, the unary * operator there is above my Python pay grade!
Curtis Rueden
@ctrueden
OK, I see, variadic unpacking. Man, no wonder Python is a nightmare for GraalVM optimizations. :sweat_smile:
Edward Evans
@elevans
@hinerm thanks again for the help this morning!
Mark Hiner
@hinerm
:+1:
Jan Eglinger
@imagejan
@hinerm @elevans there are a few reports of pyimagej not initialising: imagej/pyimagej#103 and here on the forum. Could have a look if you find the time?
Edward Evans
@elevans
@imagejan thanks for pointing that out. I'm on it
Mark Hiner
@hinerm
@elevans @imagejan isn't the endpoint specification still :skull: :skull:? IMO we should discourage its use until scijava/scyjava#23 is resolved.
@elevans also jgo is definitely not pulling in an imagej 1.x when the version is specified as e.g. 2.1.0
image.png
Edward Evans
@elevans
@hinerm yup you're absolutely right its the same issue as scijava/scyjava#23 outlines. I just tried pulling 2.1.0 and I got the same thing you did.
I haven't looked at #23 in awhile. Maybe some fresh eyes will see a solution to this thats more future proof
Edward Evans
@elevans
@imagejan thanks for taking care of those latest issues :smiley: !
Oren Amsalem
@orena1
Hi
Is it ok to ask questions here?
How can I access FIileSaver with pyimagej ?
Curtis Rueden
@ctrueden
@orena1 The best place to ask questions is forum.image.sc. But I'll write an answer on SO.
Oren Amsalem
@orena1
Thanks, I've also created a new tag for pyimagej :)
Curtis Rueden
@ctrueden
I responded. I suggest you familiarize yourself with the differences between ImageJ1 and ImageJ2—the ij.* packages are ImageJ1, whereas the PyImageJ ij gateway is ImageJ2. So there will be a disconnect between using ij.<things> and following older guides grounded in ImageJ1 with the ij.* packages.
Oren Amsalem
@orena1
THanks
Great info
Curtis Rueden
@ctrueden
:+1: