|
38 | 38 |
|
39 | 39 | The 2mm version was generated with::
|
40 | 40 |
|
41 |
| - >>> from nipype import freesurfer as fs |
| 41 | + >>> from nipype.interfaces import freesurfer as fs |
42 | 42 | >>> rs = fs.Resample()
|
43 | 43 | >>> rs.inputs.in_file = 'OASIS-TRT-20_jointfusion_DKT31_CMA_labels_in_MNI152.nii.gz'
|
44 | 44 | >>> rs.inputs.resampled_file = 'OASIS-TRT-20_jointfusion_DKT31_CMA_labels_in_MNI152_2mm.nii.gz'
|
|
56 | 56 | from nipype import config
|
57 | 57 | config.enable_provenance()
|
58 | 58 |
|
59 |
| -from nipype import (ants, afni, fsl, freesurfer, nipy, Function, DataSink) |
| 59 | +from nipype.interfaces import (ants, afni, fsl, freesurfer, nipy, Function, |
| 60 | + DataSink) |
60 | 61 | from nipype import Workflow, Node, MapNode
|
61 | 62 |
|
62 | 63 | from nipype.algorithms.rapidart import ArtifactDetect
|
|
66 | 67 | from nipype.interfaces.c3 import C3dAffineTool
|
67 | 68 | from nipype.interfaces.utility import Merge, IdentityInterface
|
68 | 69 | from nipype.utils.filemanip import filename_to_list
|
| 70 | +from nipype.workflows.rsfmri.fsl.resting import extract_noise_components |
69 | 71 |
|
70 | 72 | import numpy as np
|
71 | 73 | import scipy as sp
|
@@ -192,30 +194,6 @@ def build_filter1(motion_params, comp_norm, outliers):
|
192 | 194 | return out_files
|
193 | 195 |
|
194 | 196 |
|
195 |
| -def extract_noise_components(realigned_file, mask_file, num_components=6): |
196 |
| - """Derive components most reflective of physiological noise |
197 |
| -
|
198 |
| - Parameters |
199 |
| - ---------- |
200 |
| - realigned_file: a 4D Nifti file containing realigned volumes |
201 |
| - mask_file: a 3D Nifti file containing white matter + ventricular masks |
202 |
| - num_components: number of components to use for noise decomposition |
203 |
| -
|
204 |
| - Returns |
205 |
| - ------- |
206 |
| - components_file: a text file containing the noise components |
207 |
| - """ |
208 |
| - imgseries = nb.load(realigned_file) |
209 |
| - noise_mask = nb.load(mask_file) |
210 |
| - voxel_timecourses = imgseries.get_data()[np.nonzero(noise_mask.get_data())] |
211 |
| - voxel_timecourses = voxel_timecourses.byteswap().newbyteorder() |
212 |
| - voxel_timecourses[np.isnan(np.sum(voxel_timecourses, axis=1)), :] = 0 |
213 |
| - _, _, v = sp.linalg.svd(voxel_timecourses, full_matrices=False) |
214 |
| - components_file = os.path.join(os.getcwd(), 'noise_components.txt') |
215 |
| - np.savetxt(components_file, v[:num_components, :].T) |
216 |
| - return components_file |
217 |
| - |
218 |
| - |
219 | 197 | def extract_subrois(timeseries_file, label_file, indices):
|
220 | 198 | """Extract voxel time courses for each subcortical roi index
|
221 | 199 |
|
|
0 commit comments