Hi,
Here is the post to the bigfsf script
(https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=FSL;347a7573.1112), and
attached my modification of it (this was work in progress, and for sure
i can't promise that it is working correctly!). It requires, as Michael
mentioned, to create an fsf template containing everything but the
information about EVs and contrasts. My modification assumes, that
events are numbered, so it was specifically tailored to what i needed. I
was able to run initial tests, but feat_model crashed after using too
many EVs - so apparently there still is some severe issue with my
script. But maybe it gives you together with the Jim Porter's original
version some ideas how to tackle the handling of large number of EVs.
Since I wanted just to test some different approach, i disregarded it
after running into problems, because it was starting to create more work
load when this test was worth it to me.
But thanks, Michael, for sharing that you have been able to run an
analysis with a sufficient large number of EVs - so maybe with this in
mind I will give it another shot when I have some spare time.
wolf
On 06/06/2013 03:16 PM, Tony Jiang wrote:
> Thanks Wolf and Steve.
> The Ram shouldn't be an issue. I have just installed 24G memory in my linux box. models should be fine as they are independent from each other. I think this might be the way of how GUI load a feat model from a file. I noticed the GUI behaves differently if you manually enter the EVs compared with loading them from a file. It could be the way i create the fsf files though. I will do a line-by-line check.
>
>
> Wolf, what appraoch did you end up with? I am very interested to learn how you handled this differently.
>
> Best,
> Tony
> ________________________________________
> From: FSL - FMRIB's Software Library [[log in to unmask]] on behalf of Stephen Smith [[log in to unmask]]
> Sent: Thursday, June 06, 2013 7:40 AM
> To: [log in to unmask]
> Subject: Re: [FSL] beta series correlation
>
> Hi - apart from any GUI display size issues, the only problems with large numbers of EVs should be if:
>
> - the model/analysis is then too large for your RAM/swap/etc.
>
> - the model becomes mathematically illegal - e.g. too many EVs given the number of timepoints, or having other rank deficiency problems.
>
> Cheers.
>
>
>
>
>
>
> On 6 Jun 2013, at 12:36, wolf zinke <[log in to unmask]<mailto:[log in to unmask]>> wrote:
>
> Hi,
>
> I once tried to create automatically fsf files with a modifed version of the Bigfsf script posted by Jim Porter on this list a while ago. I also run into this Newmat issue and tried to figure out, when this problem occurs. If I remember correctly, it started after 32 EVs. Unfortunately, I gave up this approach, and thus did not dig depper into it. Bit I am also interested to learn about possible limitations in the number of EVs, and if there is a way to circumvent this problem.
>
> cheers,
> wolf
>
> On 06/06/2013 12:11 AM, Tony Jiang wrote:
> Hi, Michael
>
> Thanks for the suggestions. Do you know if there is a limit of the number of EVs feat can handle? I tried to include 20 EVs in the GLM and it ran fine. But once i put in 50 EVs (to estimate the first 50 trial's beta), feat_model threw an error of NEWMAT::INDEXEXCEPTION.
>
> I have double checked the .fsf file and dont see anything wrong here except the GLM has way too many EVs so the GUI can't display all the columns very well.
>
> Any sugestions?
> Thanks,Tony
>
>
>
> ________________________________________
> From: FSL - FMRIB's Software Library [[log in to unmask]<mailto:[log in to unmask]>] on behalf of Harms, Michael [[log in to unmask]<mailto:[log in to unmask]>]
> Sent: Wednesday, June 05, 2013 1:00 PM
> To: [log in to unmask]<mailto:[log in to unmask]>
> Subject: Re: [FSL] beta series correlation
>
> If you can create the .fsf file using scripts, then just skip the Feat GUI
> entirely and run
> feat design.fsf
> at the command line.
>
> cheers,
> -MH
> --
> Michael Harms, Ph.D.
>
> -----------------------------------------------------------
> Conte Center for the Neuroscience of Mental Disorders
> Washington University School of Medicine
> Department of Psychiatry, Box 8134
> 660 South Euclid Ave. Tel: 314-747-6173
> St. Louis, MO 63110 Email: [log in to unmask]<mailto:[log in to unmask]>
>
>
>
>
> On 6/5/13 11:23 AM, "Tony Jiang" <[log in to unmask]<mailto:[log in to unmask]>> wrote:
>
> Dear All,
>
> I was wondering if there is a quick dirty trick to run beta series
> correlation in Feat. My data has over 100 trials so I am trying to get
> an estimate of 100+ betas for each trial. but setting this up in Feat
> seems to overwhelm the GUI? I can create the .fsf file using scripts then
> if I load it to Feat GUI, it will take forever to load the model if i
> click on Full Model Setup.
>
> any suggestions are welcome!
>
> ________________________________
> The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.
>
> Kessler Foundation is proud to be recognized as one of the Best Places to Work in New Jersey.
>
> The information in this transmission is intended for official use of the Kessler Foundation. It is intended for the exclusive use of the persons or entities to which it is addressed. If you are not an intended recipient or the employee or agent responsible for delivering this transmission to an intended recipient, be aware that any disclosure, dissemination, distribution or copying of this communication, or the use of its contents, is strictly prohibited. If you received this transmission in error, please notify the sender by return e-mail and delete the material from any computer.
>
>
>
> ---------------------------------------------------------------------------
> Stephen M. Smith, Professor of Biomedical Engineering
> Associate Director, Oxford University FMRIB Centre
>
> FMRIB, JR Hospital, Headington, Oxford OX3 9DU, UK
> +44 (0) 1865 222726 (fax 222717)
> [log in to unmask]<mailto:[log in to unmask]> http://www.fmrib.ox.ac.uk/~steve
> ---------------------------------------------------------------------------
>
> Stop the cultural destruction of Tibet<http://smithinks.net>
>
>
>
>
>
> Kessler Foundation is proud to be recognized as one of the Best Places to Work in New Jersey.
>
> The information in this transmission is intended for official use of the Kessler Foundation. It is intended for the exclusive use of the persons or entities to which it is addressed. If you are not an intended recipient or the employee or agent responsible for delivering this transmission to an intended recipient, be aware that any disclosure, dissemination, distribution or copying of this communication, or the use of its contents, is strictly prohibited. If you received this transmission in error, please notify the sender by return e-mail and delete the material from any computer.
#!/bin/bash
#
# SglEvFsf
#
# created: 09.04.2013
# by zinke
#
Usage() {
cat << EOF
Usage: $0 <fsfbase> <subjlst> <runlst> <evpathtemplate> <evstems> [options]
This function replaces defined patterns in the .fsf <fsfbase> file and reads in
a set of event files <evstems> according to the <evpathtemplate>.
replacement patterns: subject name - XXsubjXX
run number - XXrunXX - as run0# if #<10
run number - XXrnumXX - as run#
run number - XXrrrXX - as r#
it expects that the event files are in three collumn format ('set fmri(shape1) 3') and applies
convolution with a gamma HRF, temporal filtering and temporal derivative.
Modified from the MakeBigfsf script of Jim Porter.
OPTIONS:
-ext event file extension (default: .ev)
-dir Output directory for the .fsf files
-m alternative mask file
-ev additional event files to be included
###########################################################
## (c) wolf zinke (2013) - part of the MaFIA toolbox ##
## > MAcaque Functional Image Analysis < ##
## for comments and questions: [log in to unmask] ##
###########################################################
EOF
exit 1
}
if [ $# -lt 4 ]; then
Usage
else
fsffl=$1
subjlst=$2
runlst=$3
evpathtmpl=$4
evstems=$5
shift 4
fi
#__________________________________________________________________________________________#
evext=".ev"
wrtdir=`pwd`
maskfl=""
addevs=""
while [ $# -gt 0 ] ;
do
case $1 in
-m) maskfl=$2
shift 2
;;
-dir) wrtdir=$2
shift 2
;;
-ext) evext=$2
shift 2
;;
-ev) addevs="$2"
shift 2
;;
-*) echo "Wrong option: <$1>"
echo ""
Usage
;;
*) break
;;
esac
done
#__________________________________________________________________________________________#
if [ ! -d $wrtdir ]; then
mkdir $wrtdir
fi
flstem=`echo $fsffl | cut -d. -f1` # get rid of the fsf extension for later renaming
for cs in $subjlst
do
echo -n "$cs"
for cr in $runlst
do
echo -n " $cr"
#__________________________________________________________________________________________#
# Edit the fsf file to match the curren subject/run
dateXchng='sed'
dateXchng=`echo "$dateXchng -e 's/XXsubjXX/$cs/g'"`
dateXchng=`echo "$dateXchng -e 's/XXrrrXX/r$cr/g'"`
dateXchng=`echo "$dateXchng -e 's/XXrnumXX/run$cr/g'"`
if [ $cr -lt 10 ]
then
dateXchng=`echo "$dateXchng -e 's/XXrunXX/run0$cr/g'"`
else
dateXchng=`echo "$dateXchng -e 's/XXrunXX/run$cr/g'"`
fi
cstem="${wrtdir}/${flstem}_${cs}_${cr}"
cfl="$cstem.fsf"
fsfXchng=`echo "$dateXchng $fsffl > $cfl"`
eval $fsfXchng
evpathXchng=`echo "echo $evpathtmpl | $dateXchng"`
cevpath=`eval $evpathXchng`
#__________________________________________________________________________________________#
# check number of volumes and adjust if required
nvol=`cat $cfl | grep 'set fmri(npts)' | cut -d " " -f3`
dtfl=`cat $cfl | grep 'set feat_files(1)' | cut -d\" -f2`
fvol=$nvol
if [ `imtest $dtfl` -eq 1 ]
then
fvol=`fslnvols $dtfl`
fi
if [ $nvol -eq $fvol ]
then
echo "feat $cfl" >> run_feat
else
echo " >>>> Data file differs in number of volumes:"
echo " $fvol instead of $nvol"
echo "# feat $cfl # different number of volumes ($fvol)!" >> run_feat
cln=`cat $cfl | grep 'set fmri(npts)'`
nvxchng=`echo "sed -e 's/$cln/set fmri(npts) $fvol/g' $cfl > ${cfl}_tmp"`
eval $nvxchng
mv ${cfl}_tmp $cfl
fi
#__________________________________________________________________________________________#
# get total number of events
nEVS=0
for cev in $evstems
do
ccnt=$(ls $cevpath/${cev}*$evext | wc -w)
nEVS=$(echo "$nEVS + $ccnt" | bc -l)
done
# ngrps=$(echo "$evstems" | wc -w)
# nCONS=$(echo "$nEVS + $ngrps" | bc -l) % if additional contrast combining all event types are implemented
nCONS=$nEVS
nreal=$((${nEVS}+${nEVS}))
#__________________________________________________________________________________________#
# set general information about the events and contrasts
echo "" >> $cfl
echo "set fmri(evs_orig) ${nEVS}" >> $cfl
echo "set fmri(evs_real) $nreal" >> $cfl
echo "set fmri(evs_vox) 0" >> $cfl
echo "set fmri(ncon_orig) ${nCONS}" >> $cfl
echo "set fmri(ncon_real) ${nCONS}" >> $cfl
echo "set fmri(nftests_orig) 0" >> $cfl
echo "set fmri(nftests_real) 0" >> $cfl
#__________________________________________________________________________________________#
# set specifications for each event
evcnt=0
for cev in $evstems
do
cevlst=$(ls $cevpath/${cev}*$evext)
ccnt=0
for cevfl in $cevlst
do
evcnt=$(($evcnt+1))
ccnt=$(($ccnt+1))
echo -n "${cev}${ccnt}"
echo "" >> $cfl
echo "set fmri(evtitle$evcnt) \"${cev}${ccnt}\"" >> $cfl
echo "set fmri(shape$evcnt) 3" >> $cfl
echo "set fmri(convolve$evcnt) 2" >> $cfl
echo "set fmri(convolve_phase$evcnt) 0" >> $cfl
echo "set fmri(tempfilt_yn$evcnt) 1" >> $cfl
echo "set fmri(deriv_yn$evcnt) 1" >> $cfl
echo "set fmri(custom$evcnt) \"$cevfl\"" >> $cfl
echo "set fmri(gammasigma$evcnt) 3" >> $cfl
echo "set fmri(gammadelay$evcnt) 6" >> $cfl
echo "" >> $cfl
for A in `seq 0 ${nEVS}`; do
echo "set fmri(ortho$evcnt.${A}) 0" >> $cfl
done
# for R in `seq 1 ${nINPUTS}`; do
# VAL=$(head -n ${R} ${XMAT} | tail -1 | awk '{print $'$evcnt'}')
# echo "set fmri(evg${R}.$evcnt) ${VAL}" >> $cfl
# done
echo ""
done
done
#__________________________________________________________________________________________#
# set specifications for the contrasts
echo "" >> $cfl
echo 'set fmri(con_mode_old) orig' >> $cfl
echo 'set fmri(con_mode) orig' >> $cfl
# contrast real
evcnt=0
for cev in $evstems
do
cevlst=$(ls $cevpath/${cev}*$evext)
ccnt=0
for cevfl in $cevlst
do
evcnt=$(($evcnt+1))
ccnt=$(($ccnt+1))
echo "" >> $cfl
echo "set fmri(conpic_real.$evcnt) 1" >> $cfl
echo "set fmri(conname_real.$evcnt) '${cev}${ccnt}'" >> $cfl
cpos=`echo "(2*$evcnt)-1" | bc -l`
for C in `seq 1 $nreal`
do
if [ $cpos -eq $C ]
then
echo "set fmri(con_real$evcnt.${C}) 1" >> $cfl
else
echo "set fmri(con_real$evcnt.${C}) 0" >> $cfl
fi
done
done
done
# contrast orig
evcnt=0
for cev in $evstems
do
cevlst=$(ls $cevpath/${cev}*$evext)
ccnt=0
for cevfl in $cevlst
do
evcnt=$(($evcnt+1))
ccnt=$(($ccnt+1))
echo "" >> $cfl
echo "set fmri(conpic_orig.$evcnt) 1" >> $cfl
echo "" >> $cfl
echo "set fmri(conname_orig.$evcnt) '${cev}${ccnt}'" >> $cfl
for C in `seq 1 ${nEVS}`
do
if [ $evcnt -eq $C ]
then
echo "set fmri(con_orig$evcnt.${C}) 1" >> $cfl
else
echo "set fmri(con_orig$evcnt.${C}) 0" >> $cfl
fi
done
done
done
#__________________________________________________________________________________________#
# set specifications for the F tests (unsed)
#
# echo Setting F-test values...
# for C in `seq 1 ${nFTESTS}`; do
# for R in `seq 1 ${nCONS}`; do
# VAL=$(head -n ${R} ${FMAT} | tail -1 | awk '{print $'${C}'}')
# echo 'set fmri(ftest_real'${C}'.'${R}') '${VAL} >> $cfl
# done
# done
#__________________________________________________________________________________________#
# set specifications for the F tests (unsed)
# Contrast masking is ususally easier to setup via the GUI.
# Just set all to 0, and do it by hand later if desired.
echo "" >> $cfl
echo "set fmri(conmask_zerothresh_yn) 0" >> $cfl
# echo "set fmri(conmask1_1) 0" >> $cfl
for A in `seq 1 ${nCONS}`
do
for B in `seq 1 ${nCONS}`
do
if [ ! $A -eq $B ]
then
echo "set fmri(conmask${A}_${B}) 0" >> $cfl
fi
done
done
echo "set fmri(conmask1_1) 0" >> $cfl
#__________________________________________________________________________________________#
# set the hidden options
echo "" >> $cfl
echo "set fmri(alternative_example_func) \"\"" >> $cfl
echo "set fmri(alternative_mask) \"$mask\"" >> $cfl
echo "set fmri(init_initial_highres) \"\"" >> $cfl
echo "set fmri(init_highres) \"\"" >> $cfl
echo "set fmri(init_standard) \"\"" >> $cfl
echo "set fmri(overwrite_yn) 0" >> $cfl
done # for cs in $subjlst
done # for cr in $runlst
feat_model $cstem
|