-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Executes program with mpiexec when using oarsub that was missed before. 2. Adds notebooks to create mu images with different values.
- Loading branch information
Showing
5 changed files
with
131 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
results/ | ||
diagnostics/ | ||
build/ | ||
buildNewNef/ | ||
|
||
/src/Makefile | ||
/GPATH | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
notebooks/.ipynb_checkpoints/create_image_from_labels-checkpoint.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"cells": [], | ||
"metadata": {}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Create images using label images and tables of desired values" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import sys\n", | ||
"sys.path.insert(0, '../scripts')\n", | ||
"\n", | ||
"def create_table_file(fname, header, label_value_pairs):\n", | ||
" '''\n", | ||
" Write a new file which starts with header and then writes\n", | ||
" in each line the label_value_pairs given as a list.\n", | ||
" '''\n", | ||
" with open(fname, 'w') as fil:\n", | ||
" fil.write(header)\n", | ||
" for pair in label_value_pairs:\n", | ||
" fil.write('%s\\t%s\\n' % (pair[0], pair[1]))\n", | ||
" return\n", | ||
"\n", | ||
"def create_image(img_file, label_value_pairs, label_img, modify_img=None):\n", | ||
" '''\n", | ||
" Creates image by putting values present in label_value_pairs in \n", | ||
" the selected labels in corresponding ROIs present in label_img.\n", | ||
" If modify_img is given update it instead of creating a new image\n", | ||
" with zero in all regions where the asked label is not present.\n", | ||
" '''\n", | ||
" import bish_utils as bu\n", | ||
" tbl_fl = 'tmp++table'\n", | ||
" header = 'labels\\tnewValues\\n'\n", | ||
" create_table_file(tbl_fl, header, label_value_pairs)\n", | ||
" cmd = ('../build/src/createImageFromLabelImage -t %s -l %s -o %s'\n", | ||
" % (tbl_fl, label_img, img_file))\n", | ||
" if modify_img:\n", | ||
" cmd += ' -m %s' % (modify_img)\n", | ||
" bu.print_and_execute(cmd)\n", | ||
" bu.print_and_execute('rm %s' % tbl_fl)\n", | ||
" " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import os as os\n", | ||
"import os.path as op\n", | ||
"\n", | ||
"in_img_dir = '/proj/asclepios/cluster/asclepios2/bkhanal/works/AdLemModel/results/patients/miriad_189_AD_M_10_MR_1'\n", | ||
"#in_img_dir = '../results/patients/miriad_189_AD_M_10_MR_1'\n", | ||
"\n", | ||
"csf_model_label = op.join(in_img_dir, 'maskwithCsfD2R0.nii.gz')\n", | ||
"#aseg_label = op.join(in_img_dir, 'aseg_cropped.nii.gz')\n", | ||
"aseg_label = op.join(in_img_dir, 'labelsWithCsfD2R0.nii.gz')\n", | ||
"\n", | ||
"out_img_dir = in_img_dir\n", | ||
"out_img = op.join(out_img_dir, 'muImageWmBstem10_GmCsf1.nii.gz')\n", | ||
"\n", | ||
"# make all tissue and CSF 1 first\n", | ||
"lab_val = [(1, 1), (2, 1)]\n", | ||
"create_image(out_img, lab_val, csf_model_label)\n", | ||
"\n", | ||
"# change labels of Brain stem and WM\n", | ||
"h_val = 10\n", | ||
"lab_val = [(16, h_val), (28, h_val), (60, h_val), (41, h_val), (2, h_val), (46, h_val), (7, h_val)]\n", | ||
"create_image(out_img, lab_val, aseg_label, out_img)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 2", | ||
"language": "python", | ||
"name": "python2" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 2 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython2", | ||
"version": "2.7.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters