Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with two censor files? #5

Open
jlhanson5 opened this issue Oct 2, 2023 · 3 comments
Open

Issue with two censor files? #5

jlhanson5 opened this issue Oct 2, 2023 · 3 comments

Comments

@jlhanson5
Copy link

Hello LNCD friends,

I kept running into errors tat-ing when I used two censor files. Basically, it looks like "-censor_rel" wasn't recognizing my second 1D file as a censor.

Here's the basic syntax I'm using:
/home/jamielh/Volumes/Hanson/Resources/lncdtools-master/tat2 /home/jamielh/Volumes/Hanson/Internal_MRI_Projects/Duke_DNS/Neuroimaging/BIDS/${i}/rest1/epiWarped.nii.gz /home/jamielh/Volumes/Hanson/Internal_MRI_Projects/Duke_DNS/Neuroimaging/BIDS/${i}/rest2/epiWarped.nii.gz -mask_rel /home/jamielh/Volumes/Hanson/Internal_MRI_Projects/Duke_DNS/Neuroimaging/BIDS/derivatives/tat/${i}/${i}_3dAutomask.nii.gz -censor_rel /home/jamielh/Volumes/Hanson/Internal_MRI_Projects/Duke_DNS/Neuroimaging/BIDS/derivatives/tat/${i}/rest1_censor.1D /home/jamielh/Volumes/Hanson/Internal_MRI_Projects/Duke_DNS/Neuroimaging/BIDS/derivatives/tat/${i}/rest2_censor.1D -output ${i}_tat_rest_COMBINED.nii.gz

And then I get this error/output:

#files/globs: 3
# [Mon 02 Oct 2023 11:58:52 AM EDT] tat2: /home/jamielh/Volumes/Hanson/Internal_MRI_Projects/Duke_DNS/Neuroimaging/BIDS/sub-0540/rest1/epiWarped.nii.gz -> /tmp/tat2star_CWri/0_tat2.nii.gz
# [Mon 02 Oct 2023 11:58:53 AM EDT] censor: using 128/128 timepoints. (last vol: 127) [/home/jamielh/Volumes/Hanson/Internal_MRI_Projects/Duke_DNS/Neuroimaging/BIDS/derivatives/tat/sub-0540/rest1_censor.1D]
++ 3dcalc: AFNI version=AFNI_23.2.02 (Jul 28 2023) [64-bit]
++ Authored by: A cast of thousands
++ Output dataset /tmp/tat2star_CWri/0_keep128_tat2.nii.gz
# [Mon 02 Oct 2023 12:00:01 PM EDT] tat2: /home/jamielh/Volumes/Hanson/Internal_MRI_Projects/Duke_DNS/Neuroimaging/BIDS/sub-0540/rest2/epiWarped.nii.gz -> /tmp/tat2star_CWri/1_tat2.nii.gz
# [Mon 02 Oct 2023 12:00:01 PM EDT] censor: using 128/128 timepoints. (last vol: 127) [/home/jamielh/Volumes/Hanson/Internal_MRI_Projects/Duke_DNS/Neuroimaging/BIDS/derivatives/tat/sub-0540/rest1_censor.1D]
++ 3dcalc: AFNI version=AFNI_23.2.02 (Jul 28 2023) [64-bit]
++ Authored by: A cast of thousands
++ Output dataset /tmp/tat2star_CWri/1_keep128_tat2.nii.gz
# [Mon 02 Oct 2023 12:01:14 PM EDT] tat2: /home/jamielh/Volumes/Hanson/Internal_MRI_Projects/Duke_DNS/Neuroimaging/BIDS/derivatives/tat/sub-0540/rest2_censor.1D -> /tmp/tat2star_CWri/2_tat2.nii.gz
# [Mon 02 Oct 2023 12:01:14 PM EDT] censor: using 128/1 timepoints. (last vol: 127) [/home/jamielh/Volumes/Hanson/Internal_MRI_Projects/Duke_DNS/Neuroimaging/BIDS/derivatives/tat/sub-0540/rest1_censor.1D]
** ERROR: selector index 1 is out of range 0..0
** Can't read 1D dataset file /home/jamielh/Volumes/Hanson/Internal_MRI_Projects/Duke_DNS/Neuroimaging/BIDS/derivatives/tat/sub-0540/rest2_censor.1D[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127]
** ERROR: selector index 1 is out of range 0..0
** ERROR: bad sub-brick selector [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127]
Warning: Cannot open input dataset /home/jamielh/Volumes/Hanson/Internal_MRI_Projects/Duke_DNS/Neuroimaging/BIDS/derivatives/tat/sub-0540/rest2_censor.1D[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127]
++ 3dcalc: AFNI version=AFNI_23.2.02 (Jul 28 2023) [64-bit]
++ Authored by: A cast of thousands
** ERROR: selector index 1 is out of range 0..0
** ERROR: selector index 1 is out of range 0..0
** Can't read 1D dataset file /home/jamielh/Volumes/Hanson/Internal_MRI_Projects/Duke_DNS/Neuroimaging/BIDS/derivatives/tat/sub-0540/rest2_censor.1D[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127]
** ERROR: selector index 1 is out of range 0..0
** ERROR: bad sub-brick selector [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127]
** FATAL ERROR: can't open dataset /home/jamielh/Volumes/Hanson/Internal_MRI_Projects/Duke_DNS/Neuroimaging/BIDS/derivatives/tat/sub-0540/rest2_censor.1D[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127]
** Program compile date = Jul 28 2023

I tried to: 1) combine my two censor files (each 128 volumes) into one combined file, but then tat2 yells at me for that; 2) use -censor_rel twice (one after another); 3) move arguments around (putting -censor_rel right after the EPI/BOLD volumes)... but nothing looks to succeed.

Things are clearly getting "misaligned" as the second EPI file is being censor with the 1st censor file, and then the script thinks the 2nd censor file is a 3rd EPI volume (and then all goes to hell). BUT I can't seem to figure out if I'm putting the arguments incorrectly on the command line/script? I hunted for some extra/funny spaces between arguments (and that didn't seem to be it... though perhaps I missed them).

Other thoughts for troubleshooting? Any ideas are much appreciated!
Jamie.

@jlhanson5
Copy link
Author

Any thoughts on this one?

@WillForan
Copy link
Contributor

an issue of bad documentation! the "rel" in the censor and motion options is "relative to each input nii.gz" and can be a file in the $(dirname $input) or s/search/replace/ style perl regexp

If I'm reading your example right, I think the files you have in /home/jamielh/Volumes/Hanson/Internal_MRI_Projects/Duke_DNS/Neuroimaging/BIDS/derivatives/tat/${i}/ are organized like

rest1/epiWarped.nii.gz
rest2/epiWarped.nii.gz
${i}_3dAutomask.nii.gz
rest1_censor.1D 
rest2_censor.1D

for the easiest call to tat2: tat2 .... -censor_rel censor.1D, you'd have the per run censor files within the rest directories and all with the same name like

rest1/epiWarped.nii.gz
rest1/censor.1D
rest2/epiWarped.nii.gz 
rest2/censor.1D
${i}_3dAutomask.nii.gz

but you can do some regular expression magic to keep it the way it is:

tats -censor_rel 's/\/epiWarped.nii.gz/_censor.1D/' ...

That's untested but the idea is to replace the last / (which has to be backslash escaped to not be interpreted as the search/replace separator) and everything after in the input nifti file name with _censor.1D

longpath/rest1/epiWarped.nii.gz becomes
longpath/rest1_censor.1D

@WillForan
Copy link
Contributor

WillForan commented Oct 18, 2023

oh and to confuse things more, -mask_rel /full/path/to/mask.nii.gz is a sneaky feature that's working in your favor. if you give an absolute path mask_rel is essentially disabled/no longer relative. instead of using a different mask for each input, tat2 uses that exact file for the mask in each of the normalization value calculations (median within mask).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants