nipy / nipype

Workflows and interfaces for neuroimaging packages
https://nipype.readthedocs.org/en/latest/
Other
745 stars 529 forks source link

localGI computation within the freesurfer interface #1514

Open fabioboh opened 8 years ago

fabioboh commented 8 years ago

Dear all,

for me, the localGI directive in the ReconAll node does not work. Basically the localGI directive (and I suspect something similar would happen to the qcache directive, which is my next step) is always changed to the autorecon2 directive, as I can see after running the workflow in the command.txt file or in the report.rst, or by just printing reconall_gyri.interface.cmdline

where I have defined (for example): reconall_gyri = pe.Node(interface=fs.ReconAll(directive='localGI',T1_files=['/scratch/igis/data/mri/nii/64-23-371-1_atd1/20160522_121506aat1mprnssagiso60364-23-371-1atd1.nii'],ignore_exception=False, subject_id ='64-23-371-1_atd1', subjects_dir='/scratch/igis/processing/nipype/smri'), name="reconall_gyri")

so basically I think this and qcache are not yet implemented in nipype (version'0.12.0-rc1' ).

am I right or is there still something I am overlooking? how can I solve the problem?

thanks

Fabio

fabioboh commented 8 years ago

Dear all,

doing some more research on the code, I now believe that the ReconAll Class defined in preprocess.py is not able to handle neither the -localGI nor the -qcache directives.

basically at line 786 in preprocess.py it is decided whether the original directive would be overwritten or not by the 'all' directive only on the basis that the directory $SUBJECTS_DIR//mri/ exists. This is always the case when one uses the -localGI directive because, as documented on teh freesurfer page, the reconall command with the localGI directive has to be launched AFTER the normal reconall command completed:

"Secondly, usage of the -localGI feature assumes that a subject has already been processed by the freesurfer {{{recon-all -s -all}}} stream, such that the ?h.pial surface files exist in the subject's /surf directory"

and the normal reconall command creates the mri subdir.

could someone please tell me whether I am right or whether I am overlooking something?

thanks a lot,

fabio

adwaykanhere commented 5 years ago

Hey Fabio,

So many years later and I'm still having the same issue. I can't run recon-all with the localGI directive and nipype just does nothing. Is there is something I can do?

Regards, Adway Kanhere

effigies commented 5 years ago

I think the problem is likely here:

https://github.com/nipy/nipype/blob/f02dd3a18b1980a86f48b552684e85c47db3d4ad/nipype/interfaces/freesurfer/preprocess.py#L1237-L1264

When we calculate what steps to check are already done based on the directive, we don't set aside qcache or localGI. I think if you change:

         directive = self.inputs.directive
-        if not isdefined(directive):
+        if not isdefined(directive) or directive in ('qcache', 'localGI'):
             steps = []
         elif directive == 'autorecon1':

This will likely resolve your issue. Would you be interested in trying this out and submitting a PR?

fabioboh commented 5 years ago

Hi Adway

some years ago I wrote a ReconAll_lGI class to solve the problem (clearly not the cleanest way to solve the problem). If the approach suggested by Chris does not work, pls come back to me when I am back from holidays (August 12th).

Cheers

Fabio

Il giorno lun 29 lug 2019 alle ore 19:33 Chris Markiewicz < notifications@github.com> ha scritto:

I think the problem is likely here:

https://github.com/nipy/nipype/blob/f02dd3a18b1980a86f48b552684e85c47db3d4ad/nipype/interfaces/freesurfer/preprocess.py#L1237-L1264

When we calculate what steps to check are already done based on the directive, we don't set aside qcache or localGI. I think if you change:

     directive = self.inputs.directive-        if not isdefined(directive):+        if not isdefined(directive) or directive in ('qcache', 'localGI'):
         steps = []
     elif directive == 'autorecon1':

This will likely resolve your issue. Would you be interested in trying this out and submitting a PR?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nipy/nipype/issues/1514?email_source=notifications&email_token=AEYRZ3NE2VXPN4DQNPAXDM3QB4SYDA5CNFSM4CHBO2E2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3BODVA#issuecomment-516088276, or mute the thread https://github.com/notifications/unsubscribe-auth/AEYRZ3KCRUVTG3TOR7DTM4TQB4SYDANCNFSM4CHBO2EQ .

-- Dr. Fabio Bernardoni Prießnitzstr. 54 01099 Dresden +49 176 9947 0149

adwaykanhere commented 5 years ago

Hey Chris,

So I've tried the approach you suggested. My code involves a separate recon-all workflow (reconwf) with the '-all' directive and another workflow for calculating localGI. The following code for setting up the workflow:

fs_folder = '/home/adway/freesurfer'
localgi = MapNode(ReconAll(directive = 'localGI', subjects_dir = fs_folder),
                   iterfield = ['subject_id'], name = "LocalGI")
localgiwf = Workflow(name = 'localgiwf')
localgiwf.base_dir = os.path.join(exp_dir, 'localgiwf')
localgiwf.connect([(reconwf, localgi, [('reconall.subject_id', 'subject_id')])
                            ])
localgiwf.run("MultiProc", plugin_args = {'n_procs' : 4})

The output :

190730-10:48:53,328 nipype.workflow INFO:
     Workflow localgiwf settings: ['check', 'execution', 'logging', 'monitoring']
190730-10:48:53,343 nipype.workflow INFO:
     Running in parallel.
190730-10:48:53,347 nipype.workflow INFO:
     [MultiProc] Running 0 tasks, and 4 jobs ready. Free memory (GB): 13.98/13.98, Free processors: 4/4.
190730-10:48:53,509 nipype.workflow INFO:
     [Node] Setting-up "localgiwf.reconallwf.fileselect" in "/home/adway/Desktop/nipypeexpdir/localgiwf/localgiwf/reconallwf/_subject_id_s1002/fileselect".
190730-10:48:53,511 nipype.workflow INFO:
     [Node] Setting-up "localgiwf.LocalGI" in "/home/adway/Desktop/nipypeexpdir/localgiwf/localgiwf/_subject_id_s1002/LocalGI".
190730-10:48:53,517 nipype.workflow INFO:
     [Node] Setting-up "localgiwf.reconallwf.fileselect" in "/home/adway/Desktop/nipypeexpdir/localgiwf/localgiwf/reconallwf/_subject_id_s1001/fileselect".
190730-10:48:53,518 nipype.workflow INFO:
     [Node] Setting-up "_fileselect0" in "/home/adway/Desktop/nipypeexpdir/localgiwf/localgiwf/reconallwf/_subject_id_s1002/fileselect/mapflow/_fileselect0".
190730-10:48:53,522 nipype.workflow INFO:
     [Node] Setting-up "_LocalGI0" in "/home/adway/Desktop/nipypeexpdir/localgiwf/localgiwf/_subject_id_s1002/LocalGI/mapflow/_LocalGI0".
190730-10:48:53,521 nipype.workflow INFO:
     [Node] Setting-up "localgiwf.LocalGI" in "/home/adway/Desktop/nipypeexpdir/localgiwf/localgiwf/_subject_id_s1001/LocalGI".
190730-10:48:53,525 nipype.workflow INFO:
     [Node] Setting-up "_fileselect0" in "/home/adway/Desktop/nipypeexpdir/localgiwf/localgiwf/reconallwf/_subject_id_s1001/fileselect/mapflow/_fileselect0".
190730-10:48:53,528 nipype.interface INFO:
     recon-all complete : Not running
190730-10:48:53,530 nipype.workflow INFO:
     [Node] Running "_fileselect0" ("nipype.interfaces.io.SelectFiles")
190730-10:48:53,531 nipype.workflow INFO:
     [Node] Running "_fileselect0" ("nipype.interfaces.io.SelectFiles")
190730-10:48:53,531 nipype.workflow INFO:
     [Node] Setting-up "_LocalGI0" in "/home/adway/Desktop/nipypeexpdir/localgiwf/localgiwf/_subject_id_s1001/LocalGI/mapflow/_LocalGI0".
190730-10:48:53,537 nipype.interface INFO:
     recon-all complete : Not running
190730-10:48:53,538 nipype.workflow INFO:
     [Node] Running "_LocalGI0" ("nipype.interfaces.freesurfer.preprocess.ReconAll"), a CommandLine Interface with command:
echo recon-all: nothing to do
190730-10:48:53,539 nipype.workflow INFO:
     [Node] Finished "_fileselect0".
190730-10:48:53,543 nipype.workflow INFO:
     [Node] Running "_LocalGI0" ("nipype.interfaces.freesurfer.preprocess.ReconAll"), a CommandLine Interface with command:
echo recon-all: nothing to do
190730-10:48:53,543 nipype.workflow INFO:
     [Node] Finished "_fileselect0".
190730-10:48:53,547 nipype.interface INFO:
     recon-all complete : Not running
190730-10:48:53,543 nipype.workflow INFO:
     [Node] Finished "localgiwf.reconallwf.fileselect".
190730-10:48:53,553 nipype.interface INFO:
     recon-all complete : Not running
190730-10:48:53,550 nipype.workflow INFO:
     [Node] Finished "localgiwf.reconallwf.fileselect".
190730-10:48:53,790 nipype.workflow INFO:
     [Node] Finished "_LocalGI0".
190730-10:48:53,791 nipype.workflow INFO:
     [Node] Finished "_LocalGI0".
190730-10:48:53,808 nipype.workflow INFO:
     [Node] Finished "localgiwf.LocalGI".
190730-10:48:53,808 nipype.workflow INFO:
     [Node] Finished "localgiwf.LocalGI".
190730-10:48:55,350 nipype.workflow INFO:
     [Job 0] Completed (localgiwf.reconallwf.fileselect).
190730-10:48:55,354 nipype.workflow INFO:
     [Job 2] Completed (localgiwf.LocalGI).
190730-10:48:55,357 nipype.workflow INFO:
     [Job 3] Completed (localgiwf.reconallwf.fileselect).
190730-10:48:55,360 nipype.workflow INFO:
     [Job 5] Completed (localgiwf.LocalGI).
190730-10:48:55,363 nipype.workflow INFO:
     [MultiProc] Running 0 tasks, and 2 jobs ready. Free memory (GB): 13.98/13.98, Free processors: 4/4.
190730-10:48:55,529 nipype.workflow INFO:
     [Job 1] Cached (localgiwf.reconallwf.reconall).
190730-10:48:55,536 nipype.workflow INFO:
     [Job 4] Cached (localgiwf.reconallwf.reconall).
<networkx.classes.digraph.DiGraph at 0x7f28e47ba240>

It seems that there is no command line argument being generated when running the localGI workflow. What can I do to solve this?

Thanks Adway

adwaykanhere commented 5 years ago

Hi Adway some years ago I wrote a ReconAll_lGI class to solve the problem (clearly not the cleanest way to solve the problem). If the approach suggested by Chris does not work, pls come back to me when I am back from holidays (August 12th). Cheers Fabio -- Dr. Fabio Bernardoni Prießnitzstr. 54 01099 Dresden +49 176 9947 0149

Hi Fabio,

Thanks for your help. I will get back to you if the problem still remains.

Warm regards Adway