Hi - a couple of comments:
Note that you do not have to find and edit any of the variables _in
place_ - you can just set them again at the bottom of the design.fsf
- i.e., if you just append settings at the end, they will take
priority over the original settings above in the file - this makes
scripting a little easier.
The other thing is that I'm slightly confused about setting the
number of timepoints by a script, separately for each input dataset,
because (unless you are just doing preprocessing with FEAT) if you
change the number of data timepoints that implies that you need to
generate a different model, so I would have thought that you need to
also change the paradigm specification variables?
Cheers, Steve.
On 13 Jan 2006, at 00:16, BettyAnn Chodkowski wrote:
> Martin,
>
> On Thu, 12 Jan 2006 15:04:22 -0500, Martin M. Monti
> <[log in to unmask]> wrote:
>
>> the problem I have is I don't know how to simply substitute variables
>> to the number/string inputs to the FEAT code.
>
> What I do is programmatically edit a saved .fsf file.
>
> I am on a sun/unix machine. My scripts are written in perl and
> bourne shell.
> The following is an example of what I do:
>
> (1) Via the FEAT GUI, create and save a .fsf file. I set the
> options as correctly as
> possible (such as TR, smoothing kernel size, etc).
>
> (2) In perl i read in this saved .fsf file. I modify (edit) this
> file and then write it out.
>
> (3) Example perl script:
>
> # slurp in $fsfFile and modify for this particular volume
> open( FSF, "< $fsfFile" ) || die( "Cannot open $fsfFile:
> $!" );
> my $fsfText = do { local $/ = undef; <FSF>; }; # read in
> whole file
> close FSF;
>
> # set TR to $tr
> $fsfText =~ s/(fmri\(tr\)).*?\n/$1 $tr \n/;
>
> # set smooth kernel size
> $fsfText =~ s/(fmri\(smooth\)).*?\n/$1 $smooth \n/;
>
> # set number of timepoint to dim4
> my $npts = doCmd( "avwnvols $fName", $doExec, $doVerbose );
> chomp( $npts ); # remove trailing newline
> $fsfText =~ s/(fmri\(npts\)).*?\n/$1 $npts \n/;
>
> # set feat_files(1) to $oFile.hdr
> $oFile = $fName;
> if ( $oFile !~ m/\.hdr$/ ) { $oFile .= '.hdr'; }
> $fsfText =~ s/(feat_files\(1\)).*?\n/$1 "$oFile"\n/;
>
> if ( !$doSliceTime ) {
> # turn off slice timing correction
> $fsfText =~ s/(fmri\(st\)).*?\n/$1 0 \n/;
> print( "SLICE TIMING CORRECTION TURNED OFF!! \n" );
> print( "SLICE TIMING CORRECTION TURNED OFF!! \n" );
> }
>
> # create a temporary .fsf file
> my ( $fsfFH, $fsfTmpFName ) = tempfile( SUFFIX=>".fsf",
> UNLINK=>$doRm );
>
> # write modified .fsf file
> open ( FSF, ">> $fsfTmpFName" ) || die( "Cannot open
> $fsfTmpFName: $!" );
> print( FSF "# have mcflirt write and save transformation
> matrices \n" );
> print( FSF "set fmri(opts__mcflirt) \"-mats\" \n" );
> print( FSF $fsfText );
> print( FSF "\n" );
> close( FSF );
>
> (4) Example bourne shell script:
> # sed template FSF to change options
> cat $designFSF | \
> sed "
> s|(tr).*|(tr) $fsl_TR|
> s|(brain_thresh).*|(brain_thresh) $fsl_BRAIN_THRESH|
> s|(smooth).*|(smooth) $fsl_SMOOTH|
> s|(reghighres_yn).*|(reghighres_yn) $fsl_REGHIGHRES_YN|
> s|(reghighres_dof).*|(reghighres_dof) $fsl_REGHIGHRES_DOF|
> s|(regstandard_yn).*|(regstandard_yn) $fsl_REGSTANDARD_YN|
> s|feat_files(1).*|feat_files(1) \"$hdrFile\"|
> s|highres_files(1).*|highres_files(1) \"$hiRez\"|
> s|(shape1).*|(shape1) $fsl_SHAPE1|
> s|(convolve1).*|(convolve1) $fsl_CONVOLVE1|
> s|(custom1).*|(custom1) $timingFile|
> 1i\\
> #+----------------------------- \\
> # Kirby Center specifics \\
> set fmri(opts__mcflirt) \"-mats\" \\
> #+-----------------------------
> " > $tmpFSF
>
> Please let me know if you have any questions about the code, but
> I'm sure you
> get the idea and then you can use whatever programming language you
> wish.
>
> Regards,
> - BettyAnn
------------------------------------------------------------------------
------------------
Stephen M. Smith, Professor of Biomedical Engineering
Associate Director, Oxford University FMRIB Centre
FMRIB, John Radcliffe Hospital, Headington, Oxford OX3 9DU, UK
+44 (0) 1865 222726 (fax 222717)
[log in to unmask] http://www.fmrib.ox.ac.uk/~steve
------------------------------------------------------------------------
------------------
|