forked from jmtyszka/bidskit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheudibids
executable file
·54 lines (42 loc) · 1.28 KB
/
heudibids
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# Wrapper for heudiconv.py conversion from Caltech-style DICOM to BIDS
# - Assumes data for each subject are in uncompressed tarballs within the DICOM directory provided
# - Creates participants.txt file in bids directory
# - Default DICOM and BIDS directories are ./dicom and ./bids
#
# USAGE: heudibids <DICOM Directory [./dicom]> <BIDS Directory [./bids]>
#
# AUTHOR : Mike Tyszka
# DATES : 2017-04-05 JMT From scratch
if [ $# -lt 1 ]; then
dcm_dir='./dicom'
else
dcm_dir=$1
fi
if [ $# -lt 2 ]; then
bids_dir='./bids'
else
bids_dir=$2
fi
echo "Input DICOM Directory: ${dcm_dir}"
echo "Output BIDS Directory: $(bids_dir)"
# Locate heuristic python script
script_path=`dirname $0`
heuristic=${script_path}/caltech_bids_heuristic.py
for tarball in ${dcm_dir}/*.tar
do
sid=`basename ${tarball%%.tar}`
# Run heuristic conversion on supplied DICOM directory
heudiconv -d "${dcm_dir}/%s.tar" -s ${sid} -o ${bids_dir} -f ${heuristic} -c dcm2niix
done
# Create participants.txt file
part_file=${bids_dir}/participants.txt
for part_dir in ${bids_dir}/*
do
# Check for participants dicom.txt file (generated by heudiconv)
dcm_file=${part_dir}/info/dicom.txt
if [ -s ${dcm_file} ]
then
echo "${part_dir} has DICOM information"
fi
done