Hoffman2:Scripts: Difference between revisions

From Center for Cognitive Neuroscience
Jump to navigation Jump to search
m (minor format edits)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
[[Hoffman2|Back to all things Hoffman2]]
[[Hoffman2|Back to all things Hoffman2]]


When you encounter a computer problem, it is best to find a systematic solution in the form of a script or program.  This lets you be prepared to handle the problem the next time you encounter it, because let's face it, history has a way of repeating itself.
When you encounter a computer problem, it is best to find a systematic solution in the form of a script or program.  This lets you be prepared to handle the problem the next time you encounter it because let's face it, history has a way of repeating itself.


Here-in lies a collection of the scripts we have built up in the Hoffman2 FMRI group for solving our most common problems.  Each script's help output is provided for searching convenience as well as example usage cases for each script.
Here-in lies a collection of the scripts we have built up in the Hoffman2 FMRI group for solving our most common problems.  Each script's help output is provided for searching convenience as well as example usage cases for each script.
Line 9: Line 9:
How to clean up after yourself and maintain within your quota space.
How to clean up after yourself and maintain within your quota space.
:[[Hoffman2:Scripts:clean_me.py|clean_me.py]]
:[[Hoffman2:Scripts:clean_me.py|clean_me.py]]


==clear_scratch.sh==
==clear_scratch.sh==
Clear out all the temporary files you kept in your [[Hoffman2:Introduction#Temporary_Storage|scratch]] directory.
Clear out all the temporary files you kept in your [[Hoffman2:Introduction#Temporary_Storage|scratch]] directory.
:[[Hoffman2:Scripts:clear_scratch.sh|clear_scratch.sh]]
:[[Hoffman2:Scripts:clear_scratch.sh|clear_scratch.sh]]


<!--==compUsage.py==
<!--==compUsage.py==
Check out how much the FMRI group has been using the cluster.  Useful to know if your job has a snow ball's chance of running before next quarter, or if Wesley's been breaking Hoffman2 again.
Check out how much the FMRI group has been using the cluster.  Useful to know if your job has a snow ball's chance of running before next quarter, or if Wesley's been breaking Hoffman2 again.
:[[Hoffman2:Scripts:compUsage.py|compUsage.py]]-->
:[[Hoffman2:Scripts:compUsage.py|compUsage.py]]-->


<!--==fix_all_home9.sh==
<!--==fix_all_home9.sh==
Line 32: Line 29:
All you want to know if when the DICOM got created and you don't have time to learn how to read DICOM files byte-wise.  Just run this script.
All you want to know if when the DICOM got created and you don't have time to learn how to read DICOM files byte-wise.  Just run this script.
:[[Hoffman2:Scripts:getDicomDate.py|getDicomDate.py]]
:[[Hoffman2:Scripts:getDicomDate.py|getDicomDate.py]]


<!--==home9_fix.sh==
<!--==home9_fix.sh==
You have a very out dated bash profile that refers to the old home9 directory.  Run this script once and all things will be fixed.
You have a very outdated bash profile that refers to the old home9 directory.  Run this script once and all things will be fixed.
:[[Hoffman2:Scripts:home9_fix.sh|home9_fix.sh]]-->
:[[Hoffman2:Scripts:home9_fix.sh|home9_fix.sh]]-->


Line 41: Line 37:
MATLAB Licenses are as valuable as gold at times of heavy computing on Hoffman2.  Use this script to find out if there is one with your name on it, or to find out who to go yell at for using too many licenses.
MATLAB Licenses are as valuable as gold at times of heavy computing on Hoffman2.  Use this script to find out if there is one with your name on it, or to find out who to go yell at for using too many licenses.
:[[Hoffman2:Scripts:matlab_license_check.sh|matlab_license_check.sh]]
:[[Hoffman2:Scripts:matlab_license_check.sh|matlab_license_check.sh]]


<!--==mkstruc.sh==
<!--==mkstruc.sh==
Line 51: Line 46:
Version consistency is important for software.  Use this to stay consistent on the version of FreeSurfer you are using.
Version consistency is important for software.  Use this to stay consistent on the version of FreeSurfer you are using.
:[[Hoffman2:Scripts:switch_freesurfer|switch_freesurfer]]
:[[Hoffman2:Scripts:switch_freesurfer|switch_freesurfer]]


==switch_fsl==
==switch_fsl==
Use this one to stay consistent on your FSL version.
Use this one to stay consistent with your FSL version.
:[[Hoffman2:Scripts:switch_fsl|switch_fsl]] -->
:[[Hoffman2:Scripts:switch_fsl|switch_fsl]] -->


==setup_subject==
==setup_subject==
Transfer Dicom data from Dicom server and do NIFTI Convert and other process.
Transfer Dicom data from the Dicom server and do NIFTI Convert and other processes.
:[[Hoffman2:Scripts:setup_subject|setup_subject]]
:[[Hoffman2:Scripts:setup_subject|setup_subject]]
:[[Hoffman2:Scripts:setup_subject_3|setup_subject_3]]
:[[Hoffman2:Scripts:setup_subject_3|setup_subject_3]]
Line 65: Line 59:
Read, edit Dicom file header information
Read, edit Dicom file header information
:[[Hoffman2:Scripts:dcmheader.py|dcmheader.py]]
:[[Hoffman2:Scripts:dcmheader.py|dcmheader.py]]
===Purpose:===
This script is to help view and edit a Dicom file header information or header of Dicom files under the same subject folder
===Usage:===
To use this script, you need to load python module first and export the library location:
module load python/3.6.1_shared
PYTHONPATH=/u/project/CCN/apps/python_libs/3.6/site-packages/
Then run the code as
python3 /u/project/CCN/apps/scripts/dcmheader.py -h
This will show you the code usage.
This code can show the header of a single dcm file, or shows specific header items in multiple files inside the same subject folder or update them.
For example, showing the full header of a dcm file
python3 /u/project/CCN/apps/scripts/dcmheader.py -f /path/to/my/dicom/file -p (or --print )
You want to use this first to find out the tags of the header items you want to check or update. For example you will get the following result
(0010, 0010) Patient's Name                      PN: '12345'
(0010, 0020) Patient ID                          LO: 12345
(0010, 0030) Patient's Birth Date                DA: '20000101'
(0010, 0040) Patient's Sex                      CS: 'F'
(0010, 1010) Patient's Age                      AS: '020Y'
(0010, 0010) is the tag for item “Patient's Name”, you need this for -c (--check) and -u (--update) options.
-c (--check) option:
This option is to view specific header items in a dcm file or the same items in all files inside the subject folder
View a single item:
python3 /u/project/CCN/apps/scripts/dcmheader.py -f /path/to/my/dicom/subject/file -c "(0010, 0010)"
View a single item in a subject folder by specifying the folder instead of a file:
python3 /u/project/CCN/apps/scripts/dcmheader.py -f /path/to/my/dicom/subject/ -c "(0010, 0010)"
View multiple items:
python3 /u/project/CCN/apps/scripts/dcmheader.py -f /path/to/my/dicom/subject/file -c  "(0010, 0010) (0010, 0020)"
python3 /u/project/CCN/apps/scripts/dcmheader.py -f /path/to/my/dicom/subject/ -c  "(0010, 0010) (0010, 0020)"
-u (--update) option:
This option is for updating specific header items, using the format as "tag=new_value"
Example:
update a single item (in this example, change the Patient's Name value to 12345_1):
python3 /u/project/CCN/apps/scripts/dcmheader.py -f /path/to/my/dicom/subject/file -u "(0010, 0010)=12345_1"
update the same item for the whole subject folder
python3 /u/project/CCN/apps/scripts/dcmheader.py -f /path/to/my/dicom/subject/ -u "(0010, 0010)=12345_1"

Latest revision as of 22:54, 5 June 2020

Back to all things Hoffman2

When you encounter a computer problem, it is best to find a systematic solution in the form of a script or program. This lets you be prepared to handle the problem the next time you encounter it because let's face it, history has a way of repeating itself.

Here-in lies a collection of the scripts we have built up in the Hoffman2 FMRI group for solving our most common problems. Each script's help output is provided for searching convenience as well as example usage cases for each script.


clean_me.py

How to clean up after yourself and maintain within your quota space.

clean_me.py

clear_scratch.sh

Clear out all the temporary files you kept in your scratch directory.

clear_scratch.sh


fix_perms.sh

Collaboration is one of the best ways to further science. So if your labmate can't work on the data you just processed for her, science has a hard time moving forward. Fix those permissions and collaborate!

fix_perms.sh

getDicomDate.py

All you want to know if when the DICOM got created and you don't have time to learn how to read DICOM files byte-wise. Just run this script.

getDicomDate.py


matlab_license_check.sh

MATLAB Licenses are as valuable as gold at times of heavy computing on Hoffman2. Use this script to find out if there is one with your name on it, or to find out who to go yell at for using too many licenses.

matlab_license_check.sh


setup_subject

Transfer Dicom data from the Dicom server and do NIFTI Convert and other processes.

setup_subject
setup_subject_3

dcmheader.py

Read, edit Dicom file header information

dcmheader.py