Open danachang opened 5 years ago
Actually, I tried directly setting ops.nchannels
= 2 , ops.rchannel
= 1, ops.gchannel
= 2, and ops.AlignToRedChannel
= 1 and it does not work. The IMG
matrix will be empty. I couldn't figure out work around. Any advice on how I should put together the file format to use Suite2P? @marius10p @carsen-stringer Deeply appreciated!
Hi Dana,
We have not encountered this data structure before. Suite2p assumes interleaved channels in the same tiff, so green/red/green/red/green red etc. If you can combine your tiffs in this fashion, then you can just run suite2p separately for each plane with the options that you set. I would recommend putting the red channel second (and then you don't have to specify rchannel, gchannel). It should work fine in this order too, but we haven't tested this order in a while.
Let us know if this doesn't work and we'd be happy to assist further.
@marius10p
Thank you so much! To double check if I understand correctly, do I need to put all the frames into one single tiff as well? Something like xxx_All.tif
? Or can I just combine red and green of the same frame into one tiff, and still have multiple files, something like xxx_frame1.tif,
xxx_frame2.tif
, where each file is just green/red?
Also, say if I have 100 frames in total for both Ch1 and Ch2, then if I do green/red/green/red fashion into one single TIFF, does this mean the new TIFF file will have 200 frames if I open it on ImageJ? Thanks!
Both of those will work, but I would recommend merging into larger tiffs for processing speed and for generally requiring fewer parameter adjustments for registration. Yes, you would have 200 frames when opening in ImageJ.
@marius10p
Thank you and I just tried merging and interleaving them into one tiff file (green/red/green/red...), but it still doesn't work.
I set ops.nchannels
= 2 , ops.rchannel
= 2, ops.gchannel
= 1, and ops0.NimgFirstRegistration
= 1 because there is only one image tiff in the folder (/Plane1/all.tif), ops0.nimgbegend
= 250, ops0.dobidi
= 0 because my signals are week and bi-directional scanning phase correlation would not work.
However, I got the below error message
Index exceeds matrix dimensions. Error in pick_reg_init (line 25) bestCC = mean(CCsort(:, 1:20), 2);
Error in blockAlignIterative (line 12) mimg = pick_reg_init(data); Error in blockReg2P (line 82) ops1{i} = blockAlignIterative(squeeze(IMG(:,:,ops.planesToProcess(i),:)), ops); Error in run_pipeline (line 53) ops1 = blockReg2P(ops); % do non-rigid registration Error in master_file_cj (line 68) run_pipeline(db(iexp), ops0);`
The issue seems to start from blockReg2P.m
% find the mean frame after aligning a random subset if ops.doRegistration [IMG] = GetRandFrames(fs, ops); )
IMG
would be empty.. I thus use debug mode in GetRandFrames
, and found that the nFr
= 1, length(fs{k})
= 1, and length(Info0)
= 1.
However, my tiff file should have 13476 frames, and indeed in Info0.ImageDescription:
it says
'ImageJ=1.51n↵images=13476↵slices=13476↵loop=false↵min=0.0↵max=7983.0↵'
So I'm really not sure what to do. Did I set ops
wrong? Or maybe the merged tiff would not work in this case? Thank you so much!!
Sorry Dana I think it's because you have an older version -- blockReg2P is no longer used in the pipeline. Can you make sure you've pulled the latest version of the code?
@carsen-stringer Thank you! I just downloaded the latest version, and realized several different variable settings. Specifically, I am confused at the rationale for setting expred,
nchannels_red
and nchannels.
In makde_db_example.m, it has example like this:
i = i+1; db(i).mouse_name = 'M150326_MP008'; db(i).date = '2015-04-09'; db(i).expred = 2; db(i).expts = [3 4 6 8]; db(i).nchannels_red = 2; db(i).nchannels = 1; db(i).gchannel = 1; db(i).nplanes = 1;
I don't understand after merging and interleaving into one TIFF file, and we have 2 channels, where red channel is channel 2 (as set in db(i).nchannels_red
), why is db(i).nchannels
not 2? I also see in another closed issue, you gave an example:
db(i).expts = [1 2]; db(i).expred = db(i).expts;
db(i).nchannels_red = 2; db(i).nchannels = 2;
Therefore, I get confused and not sure how I should set options for my purposes? Thanks!
Sorry there isn't good documentation on this. The pipeline allows you to have separate folders with different numbers of channels (say you don't collect the red channel during the whole experiment). That's when you would have expts
not equal expred
. nchannels
refers to the number of channels in expts
and nchannels_red
refers to the number of channels in expred
. In your case you should say
`
db(i).expts = 1;
db(i).nchannels = 2;
db(i).expred = db(i).expred;
db(i).nchannels_red = db(i).nchannels; ` Also, if you're comfortable with python, I'd recommend using that pipeline, we've made some upgrades to that one, and the GUI is much better. You can run the pipeline from the GUI and this part is less confusing because we don't allow different blocks of the experiment with different channel numbers :)
The python version is here: https://github.com/MouseLand/suite2p
@carsen-stringer @marius10p Thank you so much for the help! I tried these settings with the latest version of the code, and still couldn't get it work. Specifically, I am getting an error message as below:
running registration non-rigid registration chosen computing mean RED image if ~isempty(db.expred) Error using reg2P (line 55) ERROR: There are too few frames per plane for processing! Error in run_pipeline (line 38) ops1 = reg2P(ops0); % do registration Error in master_file_cj (line 104) run_pipeline(db, ops0);
I checked, and the same issue still occurs: IMG
is empty while I have 13476 frames as indicated in fields for Info0
:
Filename: 'Y:\ChiaJung\Data\Imaging\2P7\2018-09-13\6890\689_intlv.tif' FileModDate: '17-Oct-2018 05:26:19' FileSize: 7.0653e+09 Format: 'tif' FormatVersion: [] Width: 512 Height: 512 BitDepth: 16 ImageDescription: 'ImageJ=1.51n↵images=13476↵slices=13476↵loop=false↵min=0.0↵max=7983.0↵'
Can you post what your db file looks like? @marius10p will the matlab version work with such large tiffs?
db
struct with fields, same as db0:
mouse_name: '2P7'
date: '2018-09-13'
expts: 6890
expred: 6890
nchannels_red: 2
nchannels: 2
gchannel: 1
nplanes: 1
I'm sorry Marius misinformed you, the Matlab version can only work with tiffs less than 2gb, so you will have to split the tiff up into separate tiffs or use the python version
Oh, then do I need to split file into 13476 tiffs (cuz 13476 frames)? Or can I split the original file into say like 10 tiffs (where each tiff has about 1347 frames)?
10 tiffs please.
On Wed, Oct 17, 2018, 3:26 PM Chia-Jung Chang notifications@github.com wrote:
Oh, then do I need to split file into 13476 tiffs (cuz 13476 frames)? Or can I split the original file into say like 10 tiffs (where each tiff has about 1347 frames)?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cortex-lab/Suite2P/issues/152#issuecomment-430757427, or mute the thread https://github.com/notifications/unsubscribe-auth/ADwMDlMDvMWNFMSCexD4YY5OuZZRs0nIks5ul4SAgaJpZM4Xi-CX .
Thanks, will try that. Another related question about
ops0.NimgFirstRegistration = 500; % number of images to include in the first registration pass
Does the number of images here mean the number of tiffs? For example, in my case, I would set it to be 10 if I have 10 tiffs in total? If I only have 1 tiff, and then set it to 1? Thanks!!!
It means the number of images. It will automatically take an equal number of frames from each tiff, for a total of approximately 500 (500 * ceil(500/ntiffs).
Oh I see if I understand it correctly: If I have 10 tiffs in total, ntiffs
= 10, and I set NimgFirstRigistration
= 500, it will choose 50 frames from each tiff to do the first registration, and then afterwards do registration for all the rest frames in all tiffs? If I only have 1 tiff in total, ntiffs
= 1, and I set NimgFirstRegistration
= 500, it will choose 500 frames from this tiff. Correct?
Yes.
On Wed, Oct 17, 2018, 3:54 PM Chia-Jung Chang notifications@github.com wrote:
Oh I see if I understand it correctly: If I have 10 tiffs in total, ntiffs = 10, and I set NimgFirstRigistration = 500, it will choose 50 frames from each tiff to do the first registration, and then afterwards do registration for all the rest frames in all tiffs? If I only have 1 tiff in total, ntiffs = 1, and I set NimgFirstRegistration = 500, it will choose 500 frames from this tiff. Correct?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cortex-lab/Suite2P/issues/152#issuecomment-430765780, or mute the thread https://github.com/notifications/unsubscribe-auth/ADwMDoIgWVJsKp_ND9n4OqyPMHmxbuvTks5ul4r3gaJpZM4Xi-CX .
Thank you so much!! It works now!!
Hi, I am still confused at data format required for image registration after reading the README and glance through the scripts.
My 2P data is acquired with red (Ch1) and green (Ch2) channels using the Bruker system. Each plane is stored in one unique folder, where each frame is also saved as one TIFF file. Ch1 and Ch2 are also saved separately. For example, for one single plane, I would have files saved like this:
Does Suie2P assume all the frames/channels are saved in one single TIFF? Does Suite2P support this kind of file format? If yes, should I just go ahead and set
ops.nchannels = 2
,ops.rchannel = 1
,ops.gchannel = 2
, andops.AlignToRedChannel = 1
?Thanks, dana