Due by 11:59pm the evening of 9/24.
Read chapter 8.
Write a regular expression to extract (i.e. store in a regex group) the italicized portions of the following strings. The same regex should work for each set of strings.
Your expressions will be evaluated using the python mode of regex101.com
#####A BIDS-style file name (set 1)
- sub-1000_task-nback_acq-singleband_run-03_bold
- sub-EXP23_task-rest_acq-multiband_run-01_bold
#####A 10 digit US phone number (set 2): You should capture 3 groups, containing the area code, exchange and number, but not any separators or country code.
- +1 123-456-7891
- (123) 555-5555
- 860.865.9805
- 1-800-865-9805
Submit your two regular expressions in a Markdown file regex/README.md
Read at least one of the papers posted in #discussion on Slack and be prepared to discuss in class. Feel free to discuss in the #discussion channel before class!
Although shell scripting is a useful tool that we will continue to rely on, some things are better done in a more powerful language such as Python. Begin the free modules of the Python Code Academy course. You should try to get 1/3 to 1/2 through or so.
In this homework, you will practice downloading your data from NiDB and converting it into a BIDS structure.
- Input: a directory of DICOM files downloaded from NiDB, possibly containing subdirectories
- Output: a directory of NIFTI files, organized in BIDS format
- Method: You will accomplish the conversion by writing a script (located at
scripts/convert.shwith respect to the hw2 repository) that can be run in a container as
docker run [-v ...] rhancock/burc-lite <PATH>/convert.sh PARTICIPANT
where
[-v ...]is replaced by appropriate options to attach parts of your local filesystem as volumes to the container<PATH>/convert.shis the appropriate path to the scriptPARTICIPANTis the identifier for the participant to convert.
Download the IBRAIN002 (S0318ANN) data from NiDB. More documentation about NiDB is available on the Wiki
The appropriate export options are below
After downloading the data, unzip the file, which will create a directory named IBRAIN002
- Fork and clone the
bircibrain/hw2repository to your computer - Create the following directories in your
hw2folder:bids/, for your BIDS-compliant output directoryraw/, for the DICOMs you downloaded from NiDB- The existing scripts folder is where you will put your code
- Place the
IBRAIN002folder (the folder, not the contents) in yourrawdirectory.
Run the rhancock/burc-lite Docker container interactively with the appropriate -v flags to attach your hw2 directory inside the container. You can attach to /bind inside the container. You should also include -v /tmp:/tmp.
Use the dcm2bids_helper command inside the container to extract metadata from the DICOM files. This takes two arguments:
-d DICOM_DIR, whereDICOM_DIRis the path to theIBRAIN002-o OUTPUT_DIR, whereOUTPUT_DIRis the path where the BIDS files will go
This will convert the DICOMs and create some json files containing information about the scans.
scripts/dcm2bids.json contains the dictionary that matches converted DICOM files to their corresponding BIDS structure.
It contains several sections of the form:
{
"dataType": "func",
"modalityLabel": "sbref",
"customLabels": "task-words",
"criteria": {
"ProtocolName": "INSERT Correct ProtocolName",
"ImageComments": "Single-band_reference",
"PhaseEncodingDirection": "j-"
}
},
for each of these, you will need to replace the ProtocolName value in scripts/dcm2bids.json with the appropriate ProtocolName from the json file corresponding to the scan. Do this for for the
for the following "modalityLabel": "sbref"
007_IBRAIN002_fMRI_words_run1_20171114132143
013_IBRAIN002_fMRI_motor_localizer_20171114132143.nii.gz
and the following "modalityLabel": "bold" scan series:
008_IBRAIN002_fMRI_words_run1_20171114132143.nii.gz
014_IBRAIN002_fMRI_motor_localizer_20171114132143.nii.gz
Use the dcm2bids command inside the container to convert the files. You should modify scripts/convert.sh to add the appropriate commands at line 4.
In the interactive container, you can run
dcm2bids -h
to view the documentation.
You will want to set appropriate values for -d, -p (IBRAIN002), -c (the dcm2bids.json file), and -o.
- Consider which paths need to be referenced relative to your own computer and which need to referenced relative to the container
- Shell scripts can take arguments. These can be referred to using the special variable references
$1,$2, ..., where$1provides the value of the first argument after the script name. It would be useful to use$1to control which participant is processed. - Documentation for
dcm2bids
Commit your work and create a pull request. The data files will not be committed to conserve space.





