-
Notifications
You must be signed in to change notification settings - Fork 533
NF: AFNI 3dNetCorr as afni.NetCorr #3263
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
Conversation
@effigies : Hi Chris, this is WIP commit to add afni NetCorr to nipype. Everything works well when I call the interface like this:
However, when I wrap this interface in a MapNode, the workflow runs with no error, but it does not write the outputs.
Do you have any advice on this? |
The outputs should be in the workflow's working directory... Can you show the |
This may be a case where unused outputs are not saved. Try using the configuration option |
Well that was the case here. Thank you! |
76704f0
to
c013164
Compare
If the output is used as the input to another node, then it won't be deleted. While you're debugging a workflow, it's useful to have on, and then go back to the default when you're in production. |
c013164
to
539d2a6
Compare
@effigies : Thanks! Can you please review and merge this pull request? |
nipype/interfaces/afni/preprocess.py
Outdated
if not isdefined(self.inputs.out_file): | ||
prefix = self._gen_fname(self.inputs.in_file, suffix="_netcorr") | ||
else: | ||
prefix = self.inputs.out_file | ||
|
||
# All outputs should be in the same directory as the prefix | ||
out_dir = os.path.dirname(os.path.abspath(prefix)) | ||
|
||
outputs["out_matrix"] = ( | ||
fname_presuffix(prefix, suffix="_000", use_ext=False, newpath=out_dir) + ".netcc" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the output file called? I would expect, if I set netcorr.inputs.out_file
, the output file is called exactly that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@effigies : the netcorr.inputs.out_file
defines the prefix for the output.
Afni 3dNetCorr doesn't have actual output options, but it uses the prefix to write out the correlation matrix and correlation maps to the output directory.
This added function finds and returns the convention filename for the output correlation matrix.
I am also interested to return the correlation maps return to a subdirectory in the output directory. The number of these correlation maps depends on the number of regions in the input ROI label map. Do you have any idea how I can those to the output as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@effigies : Thanks for the approval.
also, do you have any idea on this?
Please let me know if my question needs more clarification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, missed this. Assuming these files exist, you can use glob
to get them. See an example here:
nipype/nipype/interfaces/fsl/model.py
Lines 459 to 490 in e9217c2
class FEAT(FSLCommand): | |
"""Uses FSL feat to calculate first level stats | |
""" | |
_cmd = "feat" | |
input_spec = FEATInputSpec | |
output_spec = FEATOutputSpec | |
def _list_outputs(self): | |
outputs = self._outputs().get() | |
is_ica = False | |
outputs["feat_dir"] = None | |
with open(self.inputs.fsf_file, "rt") as fp: | |
text = fp.read() | |
if "set fmri(inmelodic) 1" in text: | |
is_ica = True | |
for line in text.split("\n"): | |
if line.find("set fmri(outputdir)") > -1: | |
try: | |
outputdir_spec = line.split('"')[-2] | |
if os.path.exists(outputdir_spec): | |
outputs["feat_dir"] = outputdir_spec | |
except: | |
pass | |
if not outputs["feat_dir"]: | |
if is_ica: | |
outputs["feat_dir"] = glob(os.path.join(os.getcwd(), "*ica"))[0] | |
else: | |
outputs["feat_dir"] = glob(os.path.join(os.getcwd(), "*feat"))[0] | |
print("Outputs from FEATmodel:", outputs) | |
return outputs |
Also, can you run make specs
and commit the new file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! That was very helpful.
@aghayoor Just a reminder that I left a review when you have time. |
Hi @aghayoor, any chance of finishing this one up before a release? |
Hi @effigies , I was out of office for about two weeks. Thanks for your comments. I will try to address all of your comments by the end of this week. |
Afni 3dNetCorr is added to nipype. For more details, please see: https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dNetCorr.html
@effigies Hi, I addressed your comments. Could please review this new PR? |
@effigies : addressed your comment. Thanks for catching that. |
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #3263 +/- ##
=======================================
Coverage 64.70% 64.70%
=======================================
Files 302 302
Lines 39869 39906 +37
Branches 5288 5290 +2
=======================================
+ Hits 25796 25822 +26
- Misses 12984 12995 +11
Partials 1089 1089
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
This file was automatically generated by running "make specs"
Hi @effigies , I added correlation maps to the output of this module and I also committed the output file of |
Hi @effigies , just a reminder that I updated the PR. Please review when you have time. Thanks! |
Thanks for the bump! |
This is a WIP to afni NetCorr to nipype