Here is some code I used previously for this purpose:
#!/usr/bin/env sh
fslhd -x TT_avg152 > TT_avg152header.xml
fslcreatehd TT_avg152header.xml blank
while read line; do
if echo $line | grep -q NrOfVOIs; then
NrOfVOIs=`echo $line | awk '{ print $2 }'`
echo got NrOfVOIs: $NrOfVOIs
fi
if echo $line | grep -q NameOfVOI; then
NameOfVOI=`echo $line | sed -r 's/^.{11}(.*)$/\1/;s/
/_/g;s/[^A-Za-z_]//g'`
mkdir $NameOfVOI
DirSTRING=`echo "$DirSTRING"" ""$NameOfVOI"`
echo got NameOfVOI: $NameOfVOI
fi
if echo $line | grep -q NrOfVoxels; then
NrOfVoxels=`echo $line | awk '{ print $2 }'`
echo got NrOfVoxels: $NrOfVoxels
fi
Xmm=`echo $line | awk '{ print $1 }'`
Ymm=`echo $line | awk '{ print $2 }'`
Zmm=`echo $line | awk '{ print $3 }' | sed -r "s/[^0-9. -]//g"`
if echo $Xmm | grep -qE '^[0-9.-]+$'; then
Xvox=`echo "$Xmm * 0.5 + 45" | bc`
Yvox=`echo "$Ymm * 0.5 + 63" | bc`
Zvox=`echo "$Zmm * 0.5 + 36" | bc`
Xr=`python -c "print int(round($Xvox))"`
Yr=`python -c "print int(round($Yvox))"`
Zr=`python -c "print int(round($Zvox))"`
fslmaths blank -add 1 -roi $Xr 1 $Yr 1 $Zr 1 0 1 -bin
"$NameOfVOI"/"$Xr"_"$Yr"_"$Zr"
fi
done < VOIs.voi
for VOI in $DirSTRING ; do
FilesSTRING=`ls "$VOI"/*.nii.gz`
STRING=""
for file in $FilesSTRING ; do
STRING=`echo "$STRING"" -add ""$file"`
done
echo $STRING
fslmaths blank $STRING $VOI
done
This was for converting some BrainVoyager VOI files to NIFTI files. The VOI
files were basically text files with a bunch of coordinates and some header
information. The most relevant lines for you are the two fslmaths lines
where I first create a bunch of single voxel files and then add them
together.
Peace,
Matt.
-----Original Message-----
From: FSL - FMRIB's Software Library [mailto:[log in to unmask]] On Behalf
Of Michael Scheel
Sent: Wednesday, February 25, 2009 12:23 PM
To: [log in to unmask]
Subject: Re: [FSL] import ROI through text file
Hi, could you explain me how to use fslmaths to do this. I'm also
still a matlab-beginner and if that's really easy to implement there
I'd really appreciate some hints how to do it in matlab.
Thanks, Michael
On 25-Feb-09, at 12:47 AM, Steve Smith wrote:
> Hi,
>
> If your ROI is specified via a textfile of coords then you could
> script this with fslmaths but if your number of text voxels is huge
> this could be slow. Alternatively it would be trivial in matlab and
> then use save_avw to save to image file.
>
> Cheers.
>
>
> On 25 Feb 2009, at 00:32, Michael Scheel wrote:
>
>> Hi everybody, is there a way to import an ROI into fsl and make a
>> mask out of it.
>> I have a textfile in 3 column format specifying the x y z of a
>> number of voxels.
>> I'd like to import this ROI and use it as a seed region for FDT.
>>
>> Thanks, Michael
>>
>
>
>
---------------------------------------------------------------------------
> 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] http://www.fmrib.ox.ac.uk/~steve
>
---------------------------------------------------------------------------
|