This repository has been archived by the owner on Jan 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scale_and_smooth.sh
83 lines (67 loc) · 2.08 KB
/
scale_and_smooth.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
#!/bin/bash
#preproc_test.sh
# Preprocessing fMRI files with FSL - Part III: scaling = subtracting the mean image from each volume; next the volumes are concatenated in time into runs and smoothed spatially.
#Number of runs in the experiment
nruns=6
#Kernel value for smoothing
kernel=8
#Subject ID, experiment date
SubjID="19761110MRKS"
#Directory with the dicom files
DCMD="/home/elena/emoa/DATA/20130410_19761110MRKS/dicom/"
# source directory, where nii files are stored
SRCD="/home/elena/emoa/DATA/20130410_19761110MRKS/nii_files/"
#Target Directory where preprocessed files are to be stored
TGTD="/home/elena/emoa/DATA/20130410_19761110MRKS/preprocessed_nii/"
#Directory with anatomy files
ANTD="/home/elena/emoa/DATA/anatomy/converted/Angelika/"
#Anatomical image
ANAT="19761110MRKS_be_restore.nii.gz"
#Path to template
TMLD="/usr/share/fsl/5.0/data/standard/MNI152_T1_2mm_brain.nii.gz"
#Path to Functional reference image (in this case, central image of the scanning session)
FREF_PR="/home/elena/emoa/DATA/20130410_19761110MRKS/preprocessed_nii/rf_nppmultiscan_run4_0001_stc_be_mcf.nii.gz"
ext=".nii.gz"
#cd $TGTD
#1. Subtracting the mean, intensity normalization
FILE_PATTERN="*_stc_be_mcf*"
for run in `seq $nruns`
do
printf -v SUBDIR "Run%02d/" "$run"
for file in `ls $SRCD$SUBDIR$FILE_PATTERN`
do
fslmerge -t ${SubjID}_run$run $file
fslmaths ${SubjID}_run$run* -Tmean mean_run$run
done
done
suff2=_sc #scaled
for run in `seq $nruns`
do
printf -v SUBDIR "Run%02d/" "$run"
for file in `ls $SRCD$SUBDIR$FILE_PATTERN`
do
newname="${file%%.*}"
if [[ ! "$newname" =~ "$suff2" ]]; then
fslmaths $file -sub mean_run$run* $newname$suff2 #Subtract mean
#rm $file
fi
done
done
#2. Merging files into runs
#Options - concatenate in time
FILE_PATTERN="_stc_be_mcf_sc"
do
printf -v SUBDIR "Run%02d/" "$run"
for file in `ls $SRCD$SUBDIR$FILE_PATTERN`
do
fslmerge -t ${SubjID}_run$run$FILE_PATTERN *run$run?????$FILE_PATTERN*
mv ${SubjID}_run$run$FILE_PATTERN* $TGTD
done
#3. Spatial smoothing
suff=_sps
for file in `ls $TGTD$SubjID`
do
newname="${file%%.*}"
fslmaths $file -s $kernel $newname$suff$kernel
rm $file
done