Skip to content

Commit

Permalink
before auto workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mselimata committed May 27, 2024
1 parent caafe8b commit a17f484
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 42 deletions.
Binary file modified figures/colored_block.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/flat_block_detailed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 0 additions & 18 deletions src/Nipype/Notebooks/nipype_spm_preproc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@
],
"source": [
"segment = Node(NewSegment(), name=\"newsegment\")\n",
"# seg.inputs.channel_files = '/data/preproc/coregister/sub-01_T1w.nii'\n",
"#seg.inputs.channel_files = '/data/MoAEpilot_raw/sub-01/anat/sub-01_T1w.nii'\n",
"segment.inputs.affine_regularization = 'mni'\n",
"segment.inputs.channel_info = (0.001, 60, (False, True)) #save bias corrected map\n",
"tissue1 = ((tpm_path, 1), 1, (True, False), (False, False))\n",
Expand Down Expand Up @@ -284,22 +282,6 @@
"art.inputs.plot_type='png'"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"def get_vox_dims(volume):\n",
" import nibabel as nb\n",
" if isinstance(volume, list):\n",
" volume = volume[0]\n",
" nii = nb.load(volume)\n",
" hdr = nii.header\n",
" voxdims = hdr.get_zooms()\n",
" return [float(voxdims[0]), float(voxdims[1]), float(voxdims[2])]"
]
},
{
"cell_type": "code",
"execution_count": 18,
Expand Down
36 changes: 12 additions & 24 deletions src/Nipype/nipype_spm_preproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

# ## Preprocessing

# In[1]:


from nilearn import plotting
import os
import json
from nipype.interfaces import fsl
Expand All @@ -20,35 +16,26 @@

# necessary to let nipype know about matlab path



spm.SPMCommand.set_mlab_paths(paths=os.path.abspath(os.path.join(os.environ['HOME'], 'Documents/MATLAB/spm12/')), matlab_cmd='/soft/matlab_hd/R2020b/bin/glnxa64/MATLAB -nodesktop -nosplash')



mlab.MatlabCommand.set_default_matlab_cmd("/soft/matlab_hd/R2020b/bin/glnxa64/MATLAB -nodesktop -nosplash")
mlab.MatlabCommand.set_default_paths(os.path.abspath(os.path.join(os.environ['HOME'], 'Documents/MATLAB/spm12/')))




# spm.SPMCommand().version




fsl.FSLCommand.set_default_output_type('NIFTI')





base_dir = os.path.join(os.environ['HOME'], 'spmbasics/data/')





experiment_dir = os.path.join(base_dir, 'output')
output_dir = 'nipype'
working_dir = 'workingdir'
Expand All @@ -58,7 +45,7 @@

task_id = ['auditory']


# task_id = ['auditory']
# TR of functional images
with open(os.path.join(base_dir, 'MoAEpilot/task-auditory_bold.json'), 'rt') as fp:
task_info = json.load(fp)
Expand Down Expand Up @@ -108,6 +95,7 @@




slicetiming = Node(interface=SliceTiming(), name = 'slicetiming')
slicetiming.inputs.num_slices = 64
slicetiming.inputs.time_repetition = 7.
Expand All @@ -117,6 +105,9 @@
slicetiming.inputs.out_prefix = 'a'


# https://github.com/nipy/nipype/issues/2697 check this


coregister = Node(Coregister(), name="coregister")
coregister.inputs.jobtype = 'estimate'
coregister.inputs.cost_function = 'nmi'
Expand All @@ -130,7 +121,6 @@
tpm_path = os.path.abspath(os.path.join(os.environ['HOME'], 'Documents/MATLAB/spm12/tpm/', 'TPM.nii'))



segment = Node(NewSegment(), name="newsegment")
segment.inputs.affine_regularization = 'mni'
segment.inputs.channel_info = (0.001, 60, (False, True)) #save bias corrected map
Expand All @@ -147,6 +137,7 @@




normalize = Node(Normalize12(), name="normalize") #old normalize now
normalize.inputs.jobtype = 'write'
normalize.inputs.write_bounding_box = [[-78, -112, -70], [78, 76, 85]]
Expand Down Expand Up @@ -176,15 +167,6 @@
art.inputs.plot_type='png'


def get_vox_dims(volume):
import nibabel as nb
if isinstance(volume, list):
volume = volume[0]
nii = nb.load(volume)
hdr = nii.header
voxdims = hdr.get_zooms()
return [float(voxdims[0]), float(voxdims[1]), float(voxdims[2])]


block_preprocess = Workflow(name='nipype_block_preprocess')
block_preprocess.base_dir = os.path.join(experiment_dir, working_dir)
Expand Down Expand Up @@ -234,5 +216,11 @@ def get_vox_dims(volume):




block_preprocess.run('MultiProc', plugin_args={'n_procs': 4})






0 comments on commit a17f484

Please sign in to comment.