These are chat archives for thunder-project/thunder

20th
Jan 2017
Davis Bennett
@d-v-b
Jan 20 2017 02:47
@AmandaTose_twitter what does the file look like on disk? is it a single .tif file or a sequence of files?
Amanda Tose
@AmandaTose_twitter
Jan 20 2017 18:04
@d-v-b it is a single tif file, but the original file was an .avi that I had to convert to a .tif in imagej and I'm wondering if that's where a problem could have come up.
Davis Bennett
@d-v-b
Jan 20 2017 18:06
@AmandaTose_twitter I assume that thunder treats 1 file to be 1 timepoint in the fromtifmethod
which makes sense for .tif files that represent a single 3D timepoint
Amanda Tose
@AmandaTose_twitter
Jan 20 2017 18:08
@d-v-b ok it is also possible to break it into 1 tif per frame, in which case I should try loading the movie as a fromlist()?
Davis Bennett
@d-v-b
Jan 20 2017 18:11
yeah i think that might be simplest
Amanda Tose
@AmandaTose_twitter
Jan 20 2017 18:11
@d-v-b great, I'll give it a shot. thank you!
Davis Bennett
@d-v-b
Jan 20 2017 18:11
i'm playing around with some test data and I find it very weird that images.squeeze() doesn't seem to remove singleton dimensions... @jwittenbach any ideas?
also, @AmandaTose_twitter you don't necessarily need to re-save your data to use fromlist()
Amanda Tose
@AmandaTose_twitter
Jan 20 2017 18:12
@d-v-b oh? I'm not sure I understand why
Davis Bennett
@d-v-b
Jan 20 2017 18:12
suppose you have a single file vid.tif and you want to load each frame individually
then you can have a list of frames, e.g. [0,1,2,3,4...]
and your accessor can be imread(vid.tif)[frame_number]
this is super inefficient, since for every timepoint you're loading the whole video
Jason Wittenbach
@jwittenbach
Jan 20 2017 18:14
@d-v-b @AmandaTose_twitter So that’s going to be a little tricky, but I think there’s a solution
The fundamental problem is, if one allows for keeping multiple frames per file, then how do you tell the differentce between multple 2D frames and a single 3D frame?
Thunder’s default is to assume that each file is a different frame, so your single file is getting interpreted as 1 3D image
However, you can tell it that there are actually multiple images per file using the, perhaps poorly named, nplanes argument
trying something like td.images.fromtiff(/path/to/data, nplanes = 69)
Jason Wittenbach
@jwittenbach
Jan 20 2017 18:19
@d-v-b as for squeeze — it will drop singleton dimensions, but with some caveats
one of which is that the first index in an Images object it special — it represents the frames, so you can never squeeze it away
if you were able to, this would cause some issues when working in Spark mode
Amanda Tose
@AmandaTose_twitter
Jan 20 2017 18:21
@jwittenbach @d-v-b I tried rawdata = td.images.fromtiff(/path/to/data, nplanes = 69)` this which loaded my data, but when I ran rawdata.count() it still said there is 1 image
@jwittenbach @d-v-b and the shape of the file is the same
Jason Wittenbach
@jwittenbach
Jan 20 2017 18:26
@AmandaTose_twitter so when you load it with nplanes = 69, it still gives the shape as (1, 69, 480, 752)?
Amanda Tose
@AmandaTose_twitter
Jan 20 2017 18:26
@jwittenbach that's correct
Jason Wittenbach
@jwittenbach
Jan 20 2017 18:33
@AmandaTose_twitter well that’s no good. Could you try something for me? This might sound strange, but see what happens if you give it nplanes=1.
Amanda Tose
@AmandaTose_twitter
Jan 20 2017 18:35
@jwittenbach huh that worked! now the shape is (69,480,752)! I really wouldn't have guessed that
Jason Wittenbach
@jwittenbach
Jan 20 2017 18:38
yeah, there’s something strange with how that particular argument is named
looking at the code, it seems to actually function as the number of elements along the first axis of the array that should be taken together in chunks to create multiple images from the same file
Amanda Tose
@AmandaTose_twitter
Jan 20 2017 18:40
@jwittenbach when I run image(rawdata.first()), the image I get doesn't look to be in the dimensions of the actual movie even though it states them correctly and says there are 69 frames.
@jwittenbach blob
@jwittenbach this command should view a 480x752 image, right?
Jason Wittenbach
@jwittenbach
Jan 20 2017 18:41
hmm, that’s strange
so this might have something to do with how the data is laid out in the TIF
can you open the TIF as a NumPy array and see what the shape is?
maybe something like:
from tifffile import imread
img = imread(/path/to/file)
print(img.shape)
Amanda Tose
@AmandaTose_twitter
Jan 20 2017 18:43
@jwittenbach it outputs (69, 480, 752)
Jason Wittenbach
@jwittenbach
Jan 20 2017 18:43
It’s possible @boazmohar might know something about this too. I don’t use multipage TIFs much, but I think he does…and might even have written some of the nplanes code
that seems right
and what is the shape of the object that comes from doing first on the Thunder object?
Amanda Tose
@AmandaTose_twitter
Jan 20 2017 18:45
@jwittenbach sorry I'm not sure how to find the shape of the first object
Jason Wittenbach
@jwittenbach
Jan 20 2017 18:49
no problem, something like:
imgs = td.images.fromtif(/path/to/data, nplanes=1)
print(imgs.first().shape)
Amanda Tose
@AmandaTose_twitter
Jan 20 2017 18:50
@jwittenbach with that I get (480, 752)
Jason Wittenbach
@jwittenbach
Jan 20 2017 18:51
so that seems to be correct
maybe your plotting function is just giving it a strange aspect ratio?
you could matplotlib.pyplot.matshow, I think that will keep the aspect ratio at 1
Amanda Tose
@AmandaTose_twitter
Jan 20 2017 18:53
blob
that gets me this
the length is correct, but its not showing the full height
my labmate just suggested that it could be because it expects RBG input but my data is grayscale?
Jason Wittenbach
@jwittenbach
Jan 20 2017 19:02
it looks like it something strange with the plotting
you can see how it’s not going all the way to the end on the y-axis
it’s showing all 752 columns, but rows are getting cut off well before the 480 that are there
from the imgs.first().shape we can see that all the data is there
it’s just view in your plotting display is cutting it off
Amanda Tose
@AmandaTose_twitter
Jan 20 2017 19:05
yeah it seems like now I will be able to do the processing that I want to do and maybe saving it to a tif afterwards will still produce a processed video. strange the plotting is working though
Davis Bennett
@d-v-b
Jan 20 2017 19:06
try plt.imshow? i've never had any trouble displaying frames of video with that
Amanda Tose
@AmandaTose_twitter
Jan 20 2017 19:06
i just tried that, and it still produces the same shape as before
it cuts the y-axis at ~150
Davis Bennett
@d-v-b
Jan 20 2017 19:07
weird!