Print

Print


Dear Andy

I normally just use the File Selector (Batch Mode) from the BasicIO menu in the Batch Editor, remember to select “Yes” under “Descend into subdirectories”. But I am very bad at writing shell scripts.

Best
Torben

Torben Ellegaard Lund
Associate Professor, PhD
Center of Functionally Integrative Neuroscience (CFIN)
Aarhus University
Aarhus University Hospital
Building 10G, 5th floor, room 31
Noerrebrogade 44
8000 Aarhus C
Denmark
Phone: +45 7846 4380
Fax: +45 7846 4400
http://www.cfin.au.dk
[log in to unmask]




Den 20/12/2013 kl. 14.41 skrev Chris Watson <[log in to unmask]>:

My code depends on all subjects' data directories being set up the same way. So "${SUBJECT}/analysis/results" would be where the con* images live.
Here are some snippets of the code.

while read s
do
    for f in $(find ./$s -type f -name "$PAT" | grep "$SEARCH"); do
        ff=$(echo ${f} | sed s:^./::)

        echo ln -s $(pwd)/${ff} \
            $TARGET/$(echo ${ff} | sed s:/analysis/$SEARCH/:-:)
    done
done < $LIST

$LIST is a text file listing all subjects. You can also create this shell variable with e.g. regular expressions, like LIST=$(ls subject[0-9]*)
$TARGET is the target directory (Maybe "GROUP/contrast1" or something like that).
$PAT is a pattern, e.g. con_0001.
$SEARCH is to narrow down the results. For example, for some subjects that have a decent amount of motion I use ArtRepair, and I rename their results folder "results_art". (Otherwise, it would grab the contrasts from both "results" and "results_art".

The output filename would be "${SUBJECT}-$PAT.{hdr,img}". An example would be "watson_c-con_0001.img", if your subject is "watson_c". All of these contrast images will be in $TARGET, so when you go to specify 2nd level, you can just select-all.

So an example use of the script would be
collect.sh -p con_0001* \
                -t GROUP/contrast1 \
                -l subjects.txt \
                -s "results_art"

You will have to insert code to accept options, if you want. It's also easy to use this for multiple experiments; just put "case $EXPERIMENT" in front of the first line above.

Chris

On 12/20/2013 03:47 AM, Andy Yeung wrote:
[log in to unmask]" type="cite">
Dear all,

For example I got 100 subjects and several contrasts.
At 2nd level analysis I tried to copy and paste all relevant con*.img/hdr collectively into a new folder.
But it says error at running specifying 2nd level.
Is there a way to quickly allow me to pick up files I want in spm specify 2nd level?
Filter button works only when I'm into daughter folder containing the data, doesn't work when I'm in parent folder.

Yours,
Andy