help > Possible to just preprocess?
Showing 1-13 of 13 posts
Display:
Results per page:
Jan 20, 2015  08:01 PM | Jamie Hanson
Possible to just preprocess?
Hello Dr. Spielberg and colleagues,

I was interested in using GTG for just pre-processing (a colleague has a novel network detection algorithm I was trying to use). Would that be possible in GTG? I tried to input a resting state scan and a whole brain mask (for both the whole brain mask and ROI mask). I however ran into some errors. 

After clicking the preprocess button, I enter a vector for participant ID (Subjects={'2011031012401','2011031012401_rest.nii.gz'};), ROI labels (Mask={'WholeBrain','2011031012401_rest_mask.nii.gz'};), change the # of slices and TR, and select the appropriate files. I next click motion censoring (just for my piloting). I however get the following error:

>> METAlab_GTG
Warning: matlabpool will be removed in a future release.
To query the size of an already started parallel pool, query the 'NumWorkers' property of the pool.
To check if a pool is already started use 'isempty(gcp('nocreate'))'.
Error using dlmread (line 61)
The file ' ' could not be opened because: No such file or directory
Error in METAlab_GTG_preprocess_GUI>preprocess_for_graph (line 1683)
mot_pred = dlmread(par_filename);
Error in METAlab_GTG_preprocess_GUI>Start_pushbutton_Callback (line 1233)
[out.ts{currsub,1},out.num_censored_vols(currsub,1),out.num_censored_vols_FD(currsub,1),out.num_censored_vols_DVARS(currsub,1),out.GCOR(currsub,1),out.mean_FD(currsub,1),out.mean_DVARS(currsub,1)]
=
preprocess_for_graph(out,sub,logfile_fid,img_ext,func_filename,parc_filename,funcmask_filename,WM_filename,vent_filename,parc_warp_filename,WM_warp_filename,vent_warp_filename,par_filename);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in METAlab_GTG_preprocess_GUI (line 80)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)METAlab_GTG_preprocess_GUI('Start_pushbutton_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback

I'm using Matlab2014b; any thoughts on what I might have done wrong?
Any suggestions are greatly appreciated! I attached my preprocessing log (which says I'm missing files for the participant, but that file exist, etc.). Does GTG want individual (non-stacked/indexed) files?

Thanks much!
Jamie.
Jan 23, 2015  03:01 PM | Jeffrey Spielberg
RE: Possible to just preprocess?
Hi Jamie,

Yes, you can use the toolbox just for preprocessing, and you had the right idea to just use the functional brain mask for both the brainmask and ROI mask fields. 

I think what might be going wrong is how the participant IDs are entered.  Basically, there you just want to have the part of the filename that changes with each participant (so not having '_rest.nii.z' for example).  So, if you have three participants and the files were named something like:

101_rest.nii.gz
102_rest.nii.gz
103_rest.nii.gz

the cell array would be:

Subjects = {'101';'102';'103'};

(i.e., run that on the command line, then put Subjects in the appropriate field)

Also, for the array of ROI labels use this:

labels = {'wholebrain',1};

This is just telling the script that there is only one ROI, and the value of that ROI in each 3d ROI file = 1.
Jan 23, 2015  04:01 PM | Jamie Hanson
RE: Possible to just preprocess?
Thank you Dr. Spielberg for the help!
I tried to edit things accordingly, but I was still running into similar issues.
Below is my matlab output (I'm using R2014B).
I also attached a screengrab of my settings for GTG.
I also pasted my preproc_logfile below.
Any thoughts on what I might be doing wrong?

Thanks again!

Matlab output:
>> Subjects={'2011031012401';'2011031012402'};
>> labels = {'wholebrain',1};
>> METAlab_GTG
Warning: matlabpool will be removed in a future release.
To query the size of an already started parallel pool, query the 'NumWorkers' property of the pool.
To check if a pool is already started use 'isempty(gcp('nocreate'))'.
Error using dlmread (line 61)
The file ' ' could not be opened because: No such file or directory

Error in METAlab_GTG_preprocess_GUI>preprocess_for_graph (line 1683)
mot_pred = dlmread(par_filename);
Error in METAlab_GTG_preprocess_GUI>Start_pushbutton_Callback (line 1233)
[out.ts{currsub,1},out.num_censored_vols(currsub,1),out.num_censored_vols_FD(currsub,1),out.num_censored_vols_DVARS(currsub,1),out.GCOR(currsub,1),out.mean_FD(currsub,1),out.mean_DVARS(currsub,1)]
=
preprocess_for_graph(out,sub,logfile_fid,img_ext,func_filename,parc_filename,funcmask_filename,WM_filename,vent_filename,parc_warp_filename,WM_warp_filename,vent_warp_filename,par_filename);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in METAlab_GTG_preprocess_GUI (line 80)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)METAlab_GTG_preprocess_GUI('Start_pushbutton_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback

====

Output filename = /Users/jamielarshanson/Desktop/GIMME_test/Test_preproc
# of ROIs = 1
# of timepoints = 128
(User specified) TR = 2.300000e+00
The ROI timeseries were extracted after all preprocessing had occurred
Motion-censoring was performed with FD cutoff = 0.300mm and DVARS cutoff = 2.500

Base filenames:
Base filename for functional data = /Users/jamielarshanson/Desktop/GIMME_test/SUBNUM_rest.nii.gz
Base filename for functional mask = /Users/jamielarshanson/Desktop/GIMME_test/SUBNUM_rest_mask.nii.gz
Base filename for ROI mask = /Users/jamielarshanson/Desktop/GIMME_test/SUBNUM_rest_mask.nii.gz, which was input in Functional space
Data partialing:
The summary measure used to extract the timeseries from each ROI was the Mean
Participant specific information:
Attachment: GTG.png
Jan 23, 2015  04:01 PM | Jeffrey Spielberg
RE: Possible to just preprocess?
I think I see the problem.  Has the data already been motion corrected?  If not, you should click that box as well.  Even if so, I think you stumbled across a bug, whereby motion-censoring needs the motion parameters but doesn't ask for them if you don't do motion correction.  I'll include a fix in the next release of the toolbox, but try the attached script for now....

Best,
Jeff
Jan 23, 2015  06:01 PM | Jamie Hanson
RE: Possible to just preprocess?
Hmmm, now I'm getting an error related to mcflirt. Matlab output (below),
but in terminal, mcflirt looks to work just fine. Other thoughts?

Thanks again for all the help!
Jamie.


Matlab output:
>> METAlab_GTG
Warning: matlabpool will be removed in a future release.
To query the size of an already started parallel pool, query the 'NumWorkers' property of the pool.
To check if a pool is already started use 'isempty(gcp('nocreate'))'.
/bin/bash: mcflirt: command not found
Error using checkfilename>validateFilename (line 165)
Function GUNZIP was unable to find file
''/Users/jamielarshanson/Desktop/GIMME_test/2011031012402_rest_mcf.nii.gz''.

Error in checkfilename (line 49)
[fullfilename, fid] = validateFilename( ...
Error in gunzip>checkFilesURLInput (line 118)
[fullFileName, url] = checkfilename(inputFiles{1}, validExtensions, fcnName, ...
Error in gunzip (line 61)
[files, url, urlFilename] = checkFilesURLInput(files, {'gz'},'FILES',mfilename);
Error in load_nii_gz (line 66)
gunzip(filename);
Error in METAlab_GTG_preprocess_GUI>preprocess_for_graph (line 1505)
func_data = load_nii_gz(func_filename);
Error in METAlab_GTG_preprocess_GUI>Start_pushbutton_Callback (line 1235)
[out.ts{currsub,1},out.num_censored_vols(currsub,1),out.num_censored_vols_FD(currsub,1),out.num_censored_vols_DVARS(currsub,1),out.GCOR(currsub,1),out.mean_FD(currsub,1),out.mean_DVARS(currsub,1)]
=
preprocess_for_graph(out,sub,logfile_fid,img_ext,func_filename,parc_filename,funcmask_filename,WM_filename,vent_filename,parc_warp_filename,WM_warp_filename,vent_warp_filename,par_filename);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in METAlab_GTG_preprocess_GUI (line 81)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)METAlab_GTG_preprocess_GUI('Start_pushbutton_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
>>
Attachment: GTG.png
Jan 23, 2015  06:01 PM | Jeffrey Spielberg
RE: Possible to just preprocess?
It looks like the FSL paths didn't get transferred to matlab, which I've seen a few times before.  One workaround for this is to go into the matlab code (i.e., METAlab_GTG_preprocess.m) and put the whole path for mcflirt (i.e., on line 1301, replace !mcflirt with !/usr/local/fsl/bin/mcflirt or whatever the path is).  Hopefully that will work....
Jan 23, 2015  06:01 PM | Jamie Hanson
RE: Possible to just preprocess?
I updated the mcflirt path, but now was having other fsl configuration issues. Matlab output below. 

>> METAlab_GTG
Warning: matlabpool will be removed in a future release.
To query the size of an already started parallel pool, query the 'NumWorkers' property of the pool.
To check if a pool is already started use 'isempty(gcp('nocreate'))'.
ERROR:: Environment variable FSLOUTPUTTYPE is not set!
Please make sure that the appropriate configuration file is sourced by your shell (e.g. by putting it in .profile).
e.g. bash or sh users add the line ". ${FSLDIR}/etc/fslconf/fsl.sh"
e.g. tcsh or csh users add the line "source ${FSLDIR}/etc/fslconf/fsl.csh"
Error using checkfilename>validateFilename (line 165)
Function GUNZIP was unable to find file
''/Users/jamielarshanson/Desktop/GIMME_test/2011031012402_rest_mcf.nii.gz''.

===

I then updated METAlab_GTG_preprocess_GUI to include those fsl files (edits below), but it didn't seem to work/didn't fix the issue (edits below). Any other thoughts? Thanks again for the help!


if subfunc_out.MC == 1
eval(['! . /Users/jamielarshanson/Research/Software/fsl/fsl/etc/fslconf/fsl.sh ']);
eval(['!export FSLOUTPUTTYPE=NIFTI_GZ']);
eval(['!/Users/jamielarshanson/Research/Software/fsl/fsl/bin/mcflirt -in ',orig_func_filename,' -plots']);
orig_func_filename = strrep(orig_func_filename,'.nii','_mcf.nii');
par_filename = strrep(orig_func_filename,img_ext,'.par');
end
Jan 23, 2015  07:01 PM | Jeffrey Spielberg
RE: Possible to just preprocess?
I was afraid that would happen.  If you are not doing so already, try starting matlab from the command line in a terminal where FSL has been sourced normally.  Theoretically, this should pass all appropriate paths to matlab. 

If this doesn't work, there are a few more things to try....

Best,
Jeff
Jan 23, 2015  07:01 PM | Jamie Hanson
RE: Possible to just preprocess?
No luck... other thoughts?
Jan 23, 2015  07:01 PM | Jeffrey Spielberg
RE: Possible to just preprocess?
Ok, try running the code below in matlab, replacing '/usr/local/fsl' with wherever FSL is installed. Also, you can change 'NIFTI_GZ' to something else if you want a different output format....

setenv('FSLDIR','/usr/local/fsl')
path_default=getenv('PATH');
path =[path_default,':',getenv('FSLDIR'),'/bin'];
setenv('PATH',path)
setenv('FSLOUTPUTTYPE','NIFTI_GZ')
Jan 23, 2015  08:01 PM | Jamie Hanson
RE: Possible to just preprocess?
PERFECT, that did the trick! Thanks for all the assistance! With those kinks worked out, GTG looks so much more useful and user-friendly than other available preprocessing toolboxes!

One more (hopefully) quick question, I was interested in using more complex non-linear warping algorithms (ANTS; http://stnava.github.io/ANTs/) to minimize any registration issues. Thinking about GTG and also pre-processing detailed by Power (and others), would it be best to:
-First slice-time correct, rigid body realign, intensity normalize, scrub, regress out nuisance variables (all in GTG), then use non-linear registration (in ANTS) and pull ROIs values out in template space (perhaps going back to GTG)
OR
-Should I simply register a subject's T1 to my template (MNI with ROIs), invert the non-linear transform, and pull ROI values in subject space (in GTG after all those steps noted above)?

Any thoughts are greatly appreciated!
Thanks again!
Jan 23, 2015  08:01 PM | Jeffrey Spielberg
RE: Possible to just preprocess?
Great, I'm glad that worked.

RE your question, if you have a ROI template in MNI space, the easiest thing is to calculate the func to MNI warp for each participant, invert the warps, then apply that to the ROI template to get an ROI image for each participant in func space - all outside of GTG.  Then, use GTG to extract timeseries for the ROIs by selecting the warped template as the ROI mask and telling GTG that this image is in functional space.  I think this is your second option....
Jan 25, 2015  05:01 PM | Jamie Hanson
RE: Possible to just preprocess?
Again perfect!
Thanks much for the help with this!