This repository has been archived by the owner on Feb 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcounter.csh
executable file
·88 lines (57 loc) · 2.13 KB
/
counter.csh
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
#!/bin/tcsh
# Find all BIDS-formatted files and count totals
# Write info to text file
set subDirs = `find . -mindepth 1 -maxdepth 1 -type d -name "sub-*"`
# BIDS suffix labels for scans within respective BIDS folders
set anatScans = "T1w T2w PD"
set funcScans = "_dir-y_"
set fmapScans = "_dir-y-_ frequency magnitude"
set otherScans = "asset mcdespot"
set allBIDS = ( $anatScans $funcScans $fmapScans $otherScans )
if ( -f scanCounts.txt ) then
rm -f scanCounts.txt
echo Directory $allBIDS >>! scanCounts.txt
else
echo Directory $allBIDS >>! scanCounts.txt
endif
foreach subDir ( $subDirs )
set nList = ""
foreach eachBIDS ( $allBIDS )
set nScans = 0
echo `ls -R $subDir | grep -iq $eachBIDS`
if ( $? ) then
: # echo $subDir does not contain $eachBIDS scans
else
# echo $subDir contains $eachBIDS scans
set nScans = `ls -R -1 $subDir | grep -c ".*"$eachBIDS".*.nii"`
# set nScans = `ls -R -1 $subDir | grep -c ".*"$eachBIDS".*+orig.HEAD"`
endif
set nList = ( $nList $nScans )
end
echo `echo $subDir | cut -d "/" -f2` $nList
echo `echo $subDir | cut -d "/" -f2` $nList >>! scanCounts.txt
end
echo "\n" >>! scanCounts.txt
echo "SESSIONS" >>! scanCounts.txt
echo "\n" >>! scanCounts.txt
echo Directory $allBIDS >>! scanCounts.txt
foreach subDir ( $subDirs )
set sesDirs = `find ./$subDir -mindepth 1 -maxdepth 1 -type d -name "ses-*"`
foreach sesDir ( $sesDirs )
set mList = ""
foreach eachBIDS ( $allBIDS )
set mScans = 0
echo `ls -R $sesDir | grep -iq $eachBIDS`
if ( $? ) then
: # echo $sesDir does not contain $eachBIDS scans
else
# echo $sesDir contains $eachBIDS scans
set mScans = `ls -R -1 $sesDir | grep -c ".*"$eachBIDS".*.nii"`
# set mScans = `ls -R -1 $sesDir | grep -c ".*"$eachBIDS".*+orig.HEAD"`
endif
set mList = ( $mList $mScans )
end
echo `echo $sesDir | cut -d "/" -f3,4` $mList
echo `echo $sesDir | cut -d "/" -f3,4` $mList >>! scanCounts.txt
end
end