- Notifications
You must be signed in to change notification settings - Fork 536
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
Changes from 1 commit
a8ee022 6da8ee8 380d798 bfcfa94 c00dd2f File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Afni 3dNetCorr is added to nipype. For more details, please see: https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dNetCorr.html
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -29,6 +29,7 @@ | |
| LFCD, | ||
| Maskave, | ||
| Means, | ||
| NetCorr, | ||
| OutlierCount, | ||
| QualityIndex, | ||
| ROIStats, | ||
| | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| | @@ -2556,6 +2556,79 @@ def _format_arg(self, name, trait_spec, value): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return super(TCorrMap, self)._format_arg(name, trait_spec, value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class NetCorrInputSpec(AFNICommandInputSpec): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| in_file = File(exists=True, argstr="-inset %s", mandatory=True) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| in_rois = File(exists=True, argstr="-in_rois %s", mandatory=True) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mask = File(exists=True, argstr="-mask %s") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| weight_ts = File(exists=True, argstr="-weight_ts %s") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fish_z = traits.Bool(argstr="-fish_z") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| part_corr = traits.Bool(argstr="-part_corr") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ts_out = traits.Bool(argstr="-ts_out") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ts_label = traits.Bool(argstr="-ts_label") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ts_indiv = traits.Bool(argstr="-ts_indiv") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ts_wb_corr = traits.Bool(argstr="-ts_wb_corr") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ts_wb_Z = traits.Bool(argstr="-ts_wb_Z") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ts_wb_strlabel = traits.Bool(argstr="-ts_wb_strlabel") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nifti = traits.Bool(argstr="-nifti") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| output_mask_nonnull = traits.Bool(argstr="-output_mask_nonnull") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| push_thru_many_zeros = traits.Bool(argstr="-push_thru_many_zeros") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ignore_LT = traits.Bool(argstr="-ignore_LT") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| out_file = File( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name_template="%s_netcorr", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| desc="output file name part", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| argstr="-prefix %s", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| position=1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name_source="in_file", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aghayoor marked this conversation as resolved. Outdated Show resolved Hide resolved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class NetCorrOutputSpec(TraitedSpec): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| out_matrix = File(desc="output text file for correlation stats") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class NetCorr(AFNICommand): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Calculate correlation matrix of a set of ROIs (using mean time series of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| each). Several networks may be analyzed simultaneously, one per brick. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| For complete details, see the `3dTcorrMap Documentation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dNetCorr.html>`_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aghayoor marked this conversation as resolved. Outdated Show resolved Hide resolved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Examples | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| >>> from nipype.interfaces import afni | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| >>> ncorr = afni.NetCorr() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| >>> ncorr.inputs.in_file = 'functional.nii' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| >>> ncorr.inputs.mask = 'mask.nii' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| >>> ncorr.inputs.in_rois = 'rois.nii' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aghayoor marked this conversation as resolved. Outdated Show resolved Hide resolved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| >>> ncorr.inputs.ts_wb_corr = True | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| >>> ncorr.inputs.ts_wb_Z = True | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| >>> ncorr.inputs.fish_z = True | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| >>> ncorr.inputs.prefix = 'sub0.tp1.ncorr' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aghayoor marked this conversation as resolved. Outdated Show resolved Hide resolved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| >>> ncorr.cmdline # doctest: +SKIP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aghayoor marked this conversation as resolved. Outdated Show resolved Hide resolved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '3dNetCorr -prefix sub0.tp1.ncorr -inset functional.nii -mask mask.nii -in_rois rois.nii -ts_wb_corr -ts_wb_Z -fish_z' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| >>> res = ncorr.run() # doctest: +SKIP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _cmd = "3dNetCorr" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input_spec = NetCorrInputSpec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| output_spec = NetCorrOutputSpec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _list_outputs(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outputs = self.output_spec().get() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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.
Uh oh!
There was an error while loading. Please reload this page.