Skip to content

Commit

Permalink
ENH: Updated nipype node MialsrtkIntensityStandardization + integrati…
Browse files Browse the repository at this point in the history
…on to preprocessing workflow
  • Loading branch information
pdedumast committed Jan 14, 2020
1 parent 467bdd2 commit 7e7f12e
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 94 deletions.
176 changes: 125 additions & 51 deletions notebooks/srr.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -175,40 +175,65 @@
" nlmDenoise.inputs.weight = 1\n",
" \n",
" \n",
" srtkCorrectSliceIntensity_nlm = Node(interface=preprocess.MultipleMialsrtkCorrectSliceIntensity(),name='srtkCorrectSliceIntensity_nlm')\n",
" srtkCorrectSliceIntensity_nlm.inputs.bids_dir = bids_dir\n",
" srtkCorrectSliceIntensity_nlm.inputs.bids_dir = bids_dir\n",
" srtkCorrectSliceIntensity01_nlm = Node(interface=preprocess.MultipleMialsrtkCorrectSliceIntensity(),name='srtkCorrectSliceIntensity01_nlm')\n",
" srtkCorrectSliceIntensity01_nlm.inputs.bids_dir = bids_dir\n",
"\n",
" \n",
" srtkCorrectSliceIntensity = Node(interface=preprocess.MultipleMialsrtkCorrectSliceIntensity(),name='srtkCorrectSliceIntensity')\n",
" srtkCorrectSliceIntensity.inputs.bids_dir = bids_dir\n",
" srtkCorrectSliceIntensity01 = Node(interface=preprocess.MultipleMialsrtkCorrectSliceIntensity(),name='srtkCorrectSliceIntensity01')\n",
" srtkCorrectSliceIntensity01.inputs.bids_dir = bids_dir\n",
"\n",
" \n",
" srtkSliceBySliceN4BiasFieldCorrection = Node(interface=preprocess.MultipleMialsrtkSliceBySliceN4BiasFieldCorrection(), name='srtkSliceBySliceN4BiasFieldCorrection')\n",
" srtkSliceBySliceN4BiasFieldCorrection.inputs.bids_dir = bids_dir\n",
" \n",
" \n",
" srtkSliceBySliceCorrectBiasField = Node(interface=preprocess.MultipleMialsrtkSliceBySliceCorrectBiasField(), name='srtkSliceBySliceCorrectBiasField')\n",
" srtkSliceBySliceCorrectBiasField.inputs.bids_dir = bids_dir\n",
" \n",
" \n",
" srtkCorrectSliceIntensity02_nlm = Node(interface=preprocess.MultipleMialsrtkCorrectSliceIntensity(),name='srtkCorrectSliceIntensity02_nlm')\n",
" srtkCorrectSliceIntensity02_nlm.inputs.bids_dir = bids_dir\n",
"\n",
" srtkCorrectSliceIntensity02 = Node(interface=preprocess.MultipleMialsrtkCorrectSliceIntensity(),name='srtkCorrectSliceIntensity02')\n",
" srtkCorrectSliceIntensity02.inputs.bids_dir = bids_dir\n",
" \n",
" \n",
" srtkIntensityStandardization = Node(interface=preprocess.MialsrtkIntensityStandardization(),name='srtkIntensityStandardization')\n",
" srtkIntensityStandardization.inputs.bids_dir = bids_dir\n",
" \n",
" srtkIntensityStandardization_nlm = Node(interface=preprocess.MialsrtkIntensityStandardization(),name='srtkIntensityStandardization_nlm')\n",
" srtkIntensityStandardization_nlm.inputs.bids_dir = bids_dir\n",
" \n",
" \n",
" wf.connect(bg, \"T2ws\", nlmDenoise, \"input_images\")\n",
" wf.connect(bg, \"masks\", nlmDenoise, \"input_masks\")\n",
" \n",
" wf.connect(nlmDenoise, \"output_images\", srtkCorrectSliceIntensity_nlm, \"input_images\")\n",
" wf.connect(bg, \"masks\", srtkCorrectSliceIntensity_nlm, \"input_masks\")\n",
" wf.connect(nlmDenoise, \"output_images\", srtkCorrectSliceIntensity01_nlm, \"input_images\")\n",
" wf.connect(bg, \"masks\", srtkCorrectSliceIntensity01_nlm, \"input_masks\")\n",
" \n",
" wf.connect(bg, \"T2ws\", srtkCorrectSliceIntensity, \"input_images\")\n",
" wf.connect(bg, \"masks\", srtkCorrectSliceIntensity, \"input_masks\")\n",
" wf.connect(bg, \"T2ws\", srtkCorrectSliceIntensity01, \"input_images\")\n",
" wf.connect(bg, \"masks\", srtkCorrectSliceIntensity01, \"input_masks\")\n",
" \n",
" wf.connect(srtkCorrectSliceIntensity_nlm, \"output_images\", srtkSliceBySliceN4BiasFieldCorrection, \"input_images\")\n",
" wf.connect(srtkCorrectSliceIntensity01_nlm, \"output_images\", srtkSliceBySliceN4BiasFieldCorrection, \"input_images\")\n",
" wf.connect(bg, \"masks\", srtkSliceBySliceN4BiasFieldCorrection, \"input_masks\")\n",
" \n",
" #\n",
" wf.connect(srtkCorrectSliceIntensity, \"output_images\", srtkSliceBySliceCorrectBiasField, \"input_images\")\n",
" wf.connect(srtkCorrectSliceIntensity01, \"output_images\", srtkSliceBySliceCorrectBiasField, \"input_images\")\n",
" wf.connect(srtkSliceBySliceN4BiasFieldCorrection, \"output_fields\", srtkSliceBySliceCorrectBiasField, \"input_fields\")\n",
" wf.connect(bg, \"masks\", srtkSliceBySliceCorrectBiasField, \"input_masks\")\n",
" \n",
" \n",
" wf.connect(srtkSliceBySliceCorrectBiasField, \"output_images\", srtkCorrectSliceIntensity02, \"input_images\")\n",
" wf.connect(bg, \"masks\", srtkCorrectSliceIntensity02, \"input_masks\")\n",
" \n",
" wf.connect(srtkSliceBySliceN4BiasFieldCorrection, \"output_images\", srtkCorrectSliceIntensity02_nlm, \"input_images\")\n",
" wf.connect(bg, \"masks\", srtkCorrectSliceIntensity02_nlm, \"input_masks\")\n",
" \n",
" \n",
" \n",
" wf.connect(srtkCorrectSliceIntensity02, \"output_images\", srtkIntensityStandardization, \"input_images\")\n",
" \n",
" wf.connect(srtkCorrectSliceIntensity02_nlm, \"output_images\", srtkIntensityStandardization_nlm, \"input_images\")\n",
" \n",
" \n",
" \n",
"\n",
" return wf"
]
Expand All @@ -225,15 +250,15 @@
"output_type": "stream",
"text": [
"Ouput directory: /fetaldata/derivatives/superres-mri/sub-01\n",
"200114-17:11:40,420 nipype.interface INFO:\n",
"200114-18:06:15,616 nipype.interface INFO:\n",
"\t **** Processing ****\n",
"200114-17:11:40,439 nipype.workflow INFO:\n",
"200114-18:06:15,637 nipype.workflow INFO:\n",
"\t Workflow srr_preproc settings: ['check', 'execution', 'logging', 'monitoring']\n",
"200114-17:11:40,443 nipype.workflow INFO:\n",
"200114-18:06:15,644 nipype.workflow INFO:\n",
"\t Running serially.\n",
"200114-17:11:40,444 nipype.workflow INFO:\n",
"200114-18:06:15,645 nipype.workflow INFO:\n",
"\t [Node] Setting-up \"srr_preproc.bids_grabber\" in \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/bids_grabber\".\n",
"200114-17:11:40,447 nipype.workflow INFO:\n",
"200114-18:06:15,648 nipype.workflow INFO:\n",
"\t [Node] Running \"bids_grabber\" (\"nipype.interfaces.io.BIDSDataGrabber\")\n"
]
},
Expand All @@ -249,50 +274,70 @@
"name": "stdout",
"output_type": "stream",
"text": [
"200114-17:11:41,823 nipype.workflow INFO:\n",
"200114-18:06:17,87 nipype.workflow INFO:\n",
"\t [Node] Finished \"srr_preproc.bids_grabber\".\n",
"200114-17:11:41,824 nipype.workflow INFO:\n",
"\t [Node] Setting-up \"srr_preproc.srtkCorrectSliceIntensity\" in \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkCorrectSliceIntensity\".\n",
"200114-17:11:41,827 nipype.workflow INFO:\n",
"\t [Node] Cached \"srr_preproc.srtkCorrectSliceIntensity\" - collecting precomputed outputs\n",
"200114-17:11:41,827 nipype.workflow INFO:\n",
"\t [Node] \"srr_preproc.srtkCorrectSliceIntensity\" found cached.\n",
"200114-17:11:41,828 nipype.workflow INFO:\n",
"200114-18:06:17,88 nipype.workflow INFO:\n",
"\t [Node] Setting-up \"srr_preproc.srtkCorrectSliceIntensity01\" in \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkCorrectSliceIntensity01\".\n",
"200114-18:06:17,90 nipype.workflow INFO:\n",
"\t [Node] Cached \"srr_preproc.srtkCorrectSliceIntensity01\" - collecting precomputed outputs\n",
"200114-18:06:17,91 nipype.workflow INFO:\n",
"\t [Node] \"srr_preproc.srtkCorrectSliceIntensity01\" found cached.\n",
"200114-18:06:17,91 nipype.workflow INFO:\n",
"\t [Node] Setting-up \"srr_preproc.nlmDenoise\" in \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/nlmDenoise\".\n",
"200114-17:11:41,831 nipype.workflow INFO:\n",
"200114-18:06:17,94 nipype.workflow INFO:\n",
"\t [Node] Cached \"srr_preproc.nlmDenoise\" - collecting precomputed outputs\n",
"200114-17:11:41,831 nipype.workflow INFO:\n",
"200114-18:06:17,95 nipype.workflow INFO:\n",
"\t [Node] \"srr_preproc.nlmDenoise\" found cached.\n",
"200114-17:11:41,832 nipype.workflow INFO:\n",
"\t [Node] Setting-up \"srr_preproc.srtkCorrectSliceIntensity_nlm\" in \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkCorrectSliceIntensity_nlm\".\n",
"200114-17:11:41,835 nipype.workflow INFO:\n",
"\t [Node] Cached \"srr_preproc.srtkCorrectSliceIntensity_nlm\" - collecting precomputed outputs\n",
"200114-17:11:41,835 nipype.workflow INFO:\n",
"\t [Node] \"srr_preproc.srtkCorrectSliceIntensity_nlm\" found cached.\n",
"200114-17:11:41,836 nipype.workflow INFO:\n",
"200114-18:06:17,95 nipype.workflow INFO:\n",
"\t [Node] Setting-up \"srr_preproc.srtkCorrectSliceIntensity01_nlm\" in \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkCorrectSliceIntensity01_nlm\".\n",
"200114-18:06:17,98 nipype.workflow INFO:\n",
"\t [Node] Cached \"srr_preproc.srtkCorrectSliceIntensity01_nlm\" - collecting precomputed outputs\n",
"200114-18:06:17,98 nipype.workflow INFO:\n",
"\t [Node] \"srr_preproc.srtkCorrectSliceIntensity01_nlm\" found cached.\n",
"200114-18:06:17,99 nipype.workflow INFO:\n",
"\t [Node] Setting-up \"srr_preproc.srtkSliceBySliceN4BiasFieldCorrection\" in \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkSliceBySliceN4BiasFieldCorrection\".\n",
"200114-17:11:41,839 nipype.workflow INFO:\n",
"200114-18:06:17,102 nipype.workflow INFO:\n",
"\t [Node] Cached \"srr_preproc.srtkSliceBySliceN4BiasFieldCorrection\" - collecting precomputed outputs\n",
"200114-17:11:41,840 nipype.workflow INFO:\n",
"200114-18:06:17,102 nipype.workflow INFO:\n",
"\t [Node] \"srr_preproc.srtkSliceBySliceN4BiasFieldCorrection\" found cached.\n",
"200114-17:11:41,841 nipype.workflow INFO:\n",
"200114-18:06:17,103 nipype.workflow INFO:\n",
"\t [Node] Setting-up \"srr_preproc.srtkCorrectSliceIntensity02_nlm\" in \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkCorrectSliceIntensity02_nlm\".\n",
"200114-18:06:17,106 nipype.workflow INFO:\n",
"\t [Node] Cached \"srr_preproc.srtkCorrectSliceIntensity02_nlm\" - collecting precomputed outputs\n",
"200114-18:06:17,106 nipype.workflow INFO:\n",
"\t [Node] \"srr_preproc.srtkCorrectSliceIntensity02_nlm\" found cached.\n",
"200114-18:06:17,107 nipype.workflow INFO:\n",
"\t [Node] Setting-up \"srr_preproc.srtkIntensityStandardization_nlm\" in \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkIntensityStandardization_nlm\".\n",
"200114-18:06:17,110 nipype.workflow INFO:\n",
"\t [Node] Cached \"srr_preproc.srtkIntensityStandardization_nlm\" - collecting precomputed outputs\n",
"200114-18:06:17,111 nipype.workflow INFO:\n",
"\t [Node] \"srr_preproc.srtkIntensityStandardization_nlm\" found cached.\n",
"200114-18:06:17,111 nipype.workflow INFO:\n",
"\t [Node] Setting-up \"srr_preproc.srtkSliceBySliceCorrectBiasField\" in \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkSliceBySliceCorrectBiasField\".\n",
"200114-17:11:41,845 nipype.workflow INFO:\n",
"\t [Node] Running \"srtkSliceBySliceCorrectBiasField\" (\"pymialsrtk.interfaces.preprocess.MultipleMialsrtkSliceBySliceCorrectBiasField\")\n",
"... cmd: mialsrtkSliceBySliceCorrectBiasField \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkCorrectSliceIntensity/sub-01_run-5_T2w_csi.nii.gz\" \"/fetaldata/derivatives/manual_masks/sub-01/anat/sub-01_run-1_T2w_desc-brain_mask.nii.gz\" \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkSliceBySliceN4BiasFieldCorrection/sub-01_run-1_T2w_nlm_csi_sliceN4field.nii.gz\" \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkSliceBySliceCorrectBiasField/sub-01_run-5_T2w_csi_sliceFldCorrected.nii.gz\"\n",
"... cmd: mialsrtkSliceBySliceCorrectBiasField \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkCorrectSliceIntensity/sub-01_run-2_T2w_csi.nii.gz\" \"/fetaldata/derivatives/manual_masks/sub-01/anat/sub-01_run-2_T2w_desc-brain_mask.nii.gz\" \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkSliceBySliceN4BiasFieldCorrection/sub-01_run-3_T2w_nlm_csi_sliceN4field.nii.gz\" \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkSliceBySliceCorrectBiasField/sub-01_run-2_T2w_csi_sliceFldCorrected.nii.gz\"\n",
"... cmd: mialsrtkSliceBySliceCorrectBiasField \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkCorrectSliceIntensity/sub-01_run-1_T2w_csi.nii.gz\" \"/fetaldata/derivatives/manual_masks/sub-01/anat/sub-01_run-3_T2w_desc-brain_mask.nii.gz\" \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkSliceBySliceN4BiasFieldCorrection/sub-01_run-4_T2w_nlm_csi_sliceN4field.nii.gz\" \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkSliceBySliceCorrectBiasField/sub-01_run-1_T2w_csi_sliceFldCorrected.nii.gz\"\n",
"... cmd: mialsrtkSliceBySliceCorrectBiasField \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkCorrectSliceIntensity/sub-01_run-4_T2w_csi.nii.gz\" \"/fetaldata/derivatives/manual_masks/sub-01/anat/sub-01_run-4_T2w_desc-brain_mask.nii.gz\" \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkSliceBySliceN4BiasFieldCorrection/sub-01_run-5_T2w_nlm_csi_sliceN4field.nii.gz\" \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkSliceBySliceCorrectBiasField/sub-01_run-4_T2w_csi_sliceFldCorrected.nii.gz\"\n",
"... cmd: mialsrtkSliceBySliceCorrectBiasField \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkCorrectSliceIntensity/sub-01_run-6_T2w_csi.nii.gz\" \"/fetaldata/derivatives/manual_masks/sub-01/anat/sub-01_run-5_T2w_desc-brain_mask.nii.gz\" \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkSliceBySliceN4BiasFieldCorrection/sub-01_run-6_T2w_nlm_csi_sliceN4field.nii.gz\" \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkSliceBySliceCorrectBiasField/sub-01_run-6_T2w_csi_sliceFldCorrected.nii.gz\"\n",
"... cmd: mialsrtkSliceBySliceCorrectBiasField \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkCorrectSliceIntensity/sub-01_run-3_T2w_csi.nii.gz\" \"/fetaldata/derivatives/manual_masks/sub-01/anat/sub-01_run-6_T2w_desc-brain_mask.nii.gz\" \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkSliceBySliceN4BiasFieldCorrection/sub-01_run-2_T2w_nlm_csi_sliceN4field.nii.gz\" \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkSliceBySliceCorrectBiasField/sub-01_run-3_T2w_csi_sliceFldCorrected.nii.gz\"\n",
"200114-17:11:43,42 nipype.workflow INFO:\n",
"\t [Node] Finished \"srr_preproc.srtkSliceBySliceCorrectBiasField\".\n"
"200114-18:06:17,115 nipype.workflow INFO:\n",
"\t [Node] Cached \"srr_preproc.srtkSliceBySliceCorrectBiasField\" - collecting precomputed outputs\n",
"200114-18:06:17,115 nipype.workflow INFO:\n",
"\t [Node] \"srr_preproc.srtkSliceBySliceCorrectBiasField\" found cached.\n",
"200114-18:06:17,116 nipype.workflow INFO:\n",
"\t [Node] Setting-up \"srr_preproc.srtkCorrectSliceIntensity02\" in \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkCorrectSliceIntensity02\".\n",
"200114-18:06:17,119 nipype.workflow INFO:\n",
"\t [Node] Cached \"srr_preproc.srtkCorrectSliceIntensity02\" - collecting precomputed outputs\n",
"200114-18:06:17,120 nipype.workflow INFO:\n",
"\t [Node] \"srr_preproc.srtkCorrectSliceIntensity02\" found cached.\n",
"200114-18:06:17,121 nipype.workflow INFO:\n",
"\t [Node] Setting-up \"srr_preproc.srtkIntensityStandardization\" in \"/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/srtkIntensityStandardization\".\n",
"200114-18:06:17,124 nipype.workflow INFO:\n",
"\t [Node] Cached \"srr_preproc.srtkIntensityStandardization\" - collecting precomputed outputs\n",
"200114-18:06:17,124 nipype.workflow INFO:\n",
"\t [Node] \"srr_preproc.srtkIntensityStandardization\" found cached.\n",
"200114-18:06:17,262 nipype.workflow INFO:\n",
"\t Generated workflow graph: /fetaldata/derivatives/superres-mri/sub-01/srr_preproc/graph.png (graph2use=hierarchical, simple_form=True).\n"
]
},
{
"data": {
"text/plain": [
"<networkx.classes.digraph.DiGraph at 0x7fb6485bf048>"
"'/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/graph.png'"
]
},
"execution_count": 6,
Expand All @@ -302,7 +347,36 @@
],
"source": [
"m_wf = create_workflow(bids_dir, subject)\n",
"m_wf.run()"
"m_wf.run()\n",
"m_wf.write_graph()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"200114-18:06:17,407 nipype.workflow INFO:\n",
"\t Generated workflow graph: /fetaldata/derivatives/superres-mri/sub-01/srr_preproc/graph.png (graph2use=hierarchical, simple_form=True).\n"
]
},
{
"data": {
"text/plain": [
"'/fetaldata/derivatives/superres-mri/sub-01/srr_preproc/graph.png'"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"m_wf.write_graph()"
]
},
{
Expand Down
Loading

0 comments on commit 7e7f12e

Please sign in to comment.