-
Notifications
You must be signed in to change notification settings - Fork 12
/
KUL_bids_summary.sh
executable file
·112 lines (81 loc) · 3.51 KB
/
KUL_bids_summary.sh
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
#
# Creates a summary of information of the BIDS directory
# Information gathered is:
# - subjects
# - sessions
# - available data (T1w, T2w, FLAIR, func, dwi)
#
# Requires Mrtrix3
#
# @ Stefan Sunaert - UZ/KUL - [email protected]
#
# v0.1 - dd 16/02/2019 - alpha version
v="v0.1 - dd 16/02/2019"
# Source KUL_main_functions
# KUL_main_functions will:
# - Say Welcome
# - check wether all necessary software is installed (and exit if needed)
# - provide some general functions like logging
kul_main_dir=$(dirname "$0")
#source $kul_main_dir/KUL_main_functions.sh
script=$(basename "$0")
cwd=$(pwd)
#---------- MAIN -------------------------------------------------
bids_dir=BIDS
output=BIDS_info.tsv
# find all images in the bids directory
search_mri=($(find ${bids_dir} -type f | grep nii.gz | sort))
num_mri=${#search_mri[@]}
echo "Number of nifti data in the BIDS folder: $num_mri"
#echo ${search_mri[@]}
echo -e "MRI-scan, Subject, Session, Type, Scan, Site, Manufacturer, Model, Software, Coil, MagneticFieldStrength, SeriesDescription, SeriesNumber, AcquisitionType, TE, TR, TI, DIM, Dim_x, Dim_y, Dim_z, Dynamics, ETL" > $output
for i in `seq 0 $(($num_mri-1))`; do
mri=${search_mri[$i]}
echo "MRI-scan: $mri"
sub=$(echo $mri | cut -d/ -f2)
echo "Subject: $sub"
ses=$(echo $mri | cut -d/ -f3)
echo "Session: $ses"
type=$(echo $mri | cut -d/ -f4)
echo "Type: $type"
scan=$(echo $mri | awk -F_ '{print $NF}' | cut -d. -f 1)
echo "Scan: $scan"
json=${mri%%.*}.json
#echo $json
site=$(grep StationName $json | cut -d: -f2 | cut -d, -f 1)
echo "Site: $site"
manufacturer=$(grep \"Manufacturer\" $json | cut -d: -f2 | cut -d, -f 1 | tr -d '"')
echo "Manufacturer: $manufacturer"
model=$(grep \"ManufacturersModelName\" $json | cut -d: -f2 | cut -d, -f 1 | tr -d '"')
echo "Model: $model"
soft=$(grep \"SoftwareVersions\" $json | cut -d: -f2 | cut -d, -f 1 | tr -d '"')
echo "Software: $soft"
coil=$(grep \"CoilString\" $json | cut -d: -f2 | cut -d, -f 1 | tr -d '"')
echo "Coil: $coil"
MagneticFieldStrength=$(grep \"MagneticFieldStrength\" $json | cut -d: -f2 | cut -d, -f 1)
echo "MagneticFieldStrength: $MagneticFieldStrength"
SeriesDescription=$(grep \"SeriesDescription\" $json | cut -d: -f2 | cut -d, -f 1 | tr -d '"')
echo "SeriesDescription: $SeriesDescription"
SeriesNumber=$(grep \"SeriesNumber\" $json | cut -d: -f2 | cut -d, -f 1)
echo "SeriesNumber: $SeriesNumber"
AcquisitionType=$(grep \"MRAcquisitionType\" $json | cut -d: -f2 | cut -d, -f 1 | tr -d '"')
echo "AcquisitionType: $AcquisitionType"
TE=$(grep EchoTime $json | cut -d: -f2 | cut -d, -f 1)
echo "TE: $TE"
TR=$(grep -w RepetitionTime $json | cut -d: -f2 | cut -d, -f 1)
echo "TR: $TR"
TI=$(grep \"InversionTime\" $json | cut -d: -f2 | cut -d, -f 1 | tr -d '"')
echo "InversionTime: $TI"
dim=$(mrinfo $mri -ndim)
echo "Dimensions: $dim"
dim_x=$(mrinfo $mri -size | cut -d" " -f 1)
dim_y=$(mrinfo $mri -size | cut -d" " -f 2)
dim_z=$(mrinfo $mri -size | cut -d" " -f 3)
dynamics=$(mrinfo $mri -size | cut -d" " -f 4)
ETL=$(grep EchoTrainLength $json | cut -d: -f2 | cut -d, -f 1)
echo "ETL: $ETL"
echo -e "$mri, $sub, $ses, $type, $scan, $site, $manufacturer \
, $model, $soft, $coil, $MagneticFieldStrength, $SeriesDescription, $SeriesNumber \
, $AcquisitionType, $TE, $TR, $TI, $dim, $dim_x, $dim_y, $dim_z, $dynamics, $ETL" >> $output
done