📄 fmr.tff
字号:
# TextFileFormat (leave this tag as magic token!)
# BVQX file format for *.FMR files (Functional MR data)
# FMR FileVersions supported: 1, 2, 3, 4, 5
#
# Version: v0.7a
# Build: 7082720
# Date: Aug-27 2007, 8:17 PM CEST
# Author: Jochen Weber, Brain Innovation, B.V., Maastricht, NL
# URL/Info: http://wiki.brainvoyager.com/BVQXtools
# FILE FORMAT
Description:Functional MRI files
Extensions:fmr
FieldDelimiters: {[32]}
LineDelimiters: {[13, 10], [10]}
ParagraphArrays:0
SkipEmptyLines:1
Magic:|
name |range |type |magic
FMR_ldsamr |1, 1024 |regexpi |loadamrfile\:\s*\w+\s*showamrfile\:\s*\d
EndMagic
# FIELDS
ListOfFields:!
type !cond !field !datatype!format !dim !default !varname
WRTLN!!!!!!! # empty line
# on read, check file version before attempt
EXPRE!$TFFREAD !!!!!!@@ = BVQXfile(0, 'newcont', 'fmr'); if ~isempty(strfind(linecont{linec}, 'FileVersion')), @FileVersion = 2; else @FileVersion = 1; end
FIELD!@FileVersion > 1 !FileVersion !double !%d !1 !4 !FileVersion
FLIST! !NrOfVolumes !double !%d !1 ! !NrOfVolumes
FLIST! !NrOfSlices !double !%d !1 ! !NrOfSlices
# FileVersion 1
BLOOP!@FileVersion == 1 !HasFV1 !!!1 !!HasFV1
FLIST! !NrOfFirstVolume !double !%d !1 ! !NrOfFirstVolume
FLIST! !NrOfFirstSlice !double !%d !1 ! !NrOfFirstSlice
ELOOP! !HasFV1 !!! !!HasFV1
# FileVersion denoted
FIELD!@FileVersion > 1 !NrOfSkippedVolumes !double !%d !1 ! !NrOfSkippedVolumes
FIELD!@FileVersion < 5 !Prefix !string !%s !1 ! !Prefix
FIELD!@FileVersion > 4 !Prefix !string !"%s" !1 ! !Prefix
FIELD!@FileVersion > 4 !DataStorageFormat !double !%d !1 !2 !DataStorageFormat
EXPRE!$TFFREAD && @FileVersion < 5 !!!!!!@DataStorageFormat = 1;
FLIST! !TR !double !%d !1 ! !TR
FLIST! !InterSliceTime !double !%d !1 ! !InterSliceTime
FLIST!@FileVersion > 1 !TimeResolutionVerified !double !%d !1 ! !TimeResolutionVerified
FIELD!@FileVersion > 4 !TE !double !%d !1 ! !TE
EXPRE!$TFFREAD && @FileVersion < 5 !!!!!!@TE = 30;
FIELD!@FileVersion > 3 !SliceAcquisitionOrder !double !%d !1 ! !SliceAcquisitionOrder
FIELD!@FileVersion > 3 !SliceAcquisitionOrderVerified !double !%d !1 ! !SliceAcquisitionOrderVerified
EXPRE!$TFFREAD && @FileVersion < 4 !!!!!!@SliceAcquisitionOrder = []; @SliceAcquisitionOrderVerified = [];
FLIST! !ResolutionX !double !%d !1 ! !ResolutionX
FLIST! !ResolutionY !double !%d !1 ! !ResolutionY
FLIST! !LoadAMRFile !string !"%s" !1 ! !LoadAMRFile
FLIST! !ShowAMRFile !double !%d !1 ! !ShowAMRFile
FLIST! !ImageIndex !double !%d !1 ! !ImageIndex
FLIST! !LayoutNColumns !double !%d !1 ! !LayoutNColumns
FLIST! !LayoutNRows !double !%d !1 ! !LayoutNRows
FLIST! !LayoutZoomLevel !double !%d !1 ! !LayoutZoomLevel
FLIST! !SegmentSize !double !%d !1 ! !SegmentSize
FLIST! !SegmentOffset !double !%d !1 ! !SegmentOffset
FIELD!@FileVersion > 4 !NrOfLinkedProtocols !double !%d !1 !1 !NrOfLinkedProtocols
EXPRE!$TFFREAD && @FileVersion < 5 !!!!!!@NrOfLinkedProtocols = 1;
FIELD!@FileVersion < 5 !ProtocolVersion !double !%d !1 !2 !ProtocolVersion
EXPRE!$TFFREAD && @FileVersion > 4 !!!!!!@ProtocolVersion = 2;
FLIST! !ProtocolFile !string !"%s" !1 ! !ProtocolFile
# Fields for FileVersion > 1
BLOOP!@FileVersion > 1 !HasFV2Plus !!!1 !!HasFV2Plus
FLIST! !InplaneResolutionX !double !%f !1 ! !InplaneResolutionX
FLIST! !InplaneResolutionY !double !%f !1 ! !InplaneResolutionY
FLIST! !SliceThickness !double !%f !1 ! !SliceThickness
FLIST! !SliceGap !double !%f !1 ! !SliceGap
FLIST! !VoxelResolutionVerified!double !%d !1 ! !VoxelResolutionVerified
ELOOP! !HasFV2Plus !!! !!HasFV2Plus
# Fields for FileVersion > 2
BLOOP!@FileVersion > 2 !HasFV3Plus !!!1 !!HasFV3Plus
WRTLN!!!!!!! # empty line
WRTLN!!!!!!! # empty line
WRTLN!!!!!!!PositionInformationFromImageHeaders
WRTLN!!!!!!! # empty line
FIELD! !PosInfosVerified !double !%d !1 !0 !PosInfosVerified
FIELD! !CoordinateSystem !double !%d !1 !0 !CoordinateSystem
FLIST! !Slice1CenterX !double !%8.5f !1 ! !Slice1CenterX
FLIST! !Slice1CenterY !double !%8.5f !1 ! !Slice1CenterY
FLIST! !Slice1CenterZ !double !%8.5f !1 ! !Slice1CenterZ
FLIST! !SliceNCenterX !double !%8.5f !1 ! !SliceNCenterX
FLIST! !SliceNCenterY !double !%8.5f !1 ! !SliceNCenterY
FLIST! !SliceNCenterZ !double !%8.5f !1 ! !SliceNCenterZ
EXPRE!1 == 0 !!!!!!; # needed for MATLAB R13, regexp/i bug with too long pattern
FLIST! !RowDirX !double !%f !1 ! !RowDirX
FLIST! !RowDirY !double !%f !1 ! !RowDirY
FLIST! !RowDirZ !double !%f !1 ! !RowDirZ
FLIST! !ColDirX !double !%f !1 ! !ColDirX
FLIST! !ColDirY !double !%f !1 ! !ColDirY
FLIST! !ColDirZ !double !%f !1 ! !ColDirZ
EXPRE!1 == 0 !!!!!!; # needed for MATLAB R13, regexp/i bug with too long pattern
FLIST! !NRows !double !%d !1 ! !NRows
FLIST! !NCols !double !%d !1 ! !NCols
FLIST! !FoVRows !double !%d !1 ! !FoVRows
FLIST! !FoVCols !double !%d !1 ! !FoVCols
# Must be fields (no colon!)
FIELD! !SliceThickness !double !%f !1 ! !SliceThickness
FIELD! !GapThickness !double !%f !1 ! !GapThickness
WRTLN!!!!!!! # empty line
WRTLN!!!!!!! # empty line
FIELD! !NrOfPastSpatialTransformations!double !%d !1 ! !NrOfPastSpatialTransformations
# If past transformations
EXPRE!$TFFREAD !!!!!!@Trf = cell2struct(cell(0, 0, 5), {'NameOfSpatialTransformation', 'TypeOfSpatialTransformation', 'AppliedToFile', 'NrOfTransformationValues', 'TrfMatrix'}, 3);
BLOOP!@NrOfPastSpatialTransformations > 0 !PastST!!!@NrOfPastSpatialTransformations !!PastST
FLIST! !NameOfSpatialTransformation !string !"%s"!1 ! !Trf($PastST).NameOfSpatialTransformation
FLIST! !TypeOfSpatialTransformation !string !%d !1 ! !Trf($PastST).TypeOfSpatialTransformation
FLIST! !AppliedToFile !string !"%s" !1 ! !Trf($PastST).AppliedToFile
FLIST! !NrOfTransformationValues!double !%d !1 ! !Trf($PastST).NrOfTransformationValues
ARRAY!@Trf($PastST).TypeOfSpatialTransformation == 1 !TrfMatrix!double !%.6f !3, 3 !Trf($PastST).TrfMatrix
ARRAY!@Trf($PastST).TypeOfSpatialTransformation == 2 !TrfMatrix!double !%.6f !4, 4 !Trf($PastST).TrfMatrix
ARRAY!@Trf($PastST).TypeOfSpatialTransformation > 2 !TrfMatrix!double !%.6f !3, 3 !Trf($PastST).TrfMatrix
ELOOP! !PastST !!! !!PastST
# otherwise
WRTLN!@NrOfPastSpatialTransformations == 0 !!!!!! # empty line
WRTLN!@NrOfPastSpatialTransformations == 0 !!!!!! # empty line
# Either Convention or RadiologicalConvention
FLIST!@FileVersion < 4 !Convention !double !%d !1 ! !Convention
FLIST!@FileVersion > 3 !RadiologicalConvention !string !%s !1 !YES !RadiologicalConvention
# Two more empty lines
WRTLN!@FileVersion > 3 !!!!!! # empty line
WRTLN!@FileVersion > 3 !!!!!! # empty line
FIELD!@FileVersion > 3 !FirstDataSourceFile !string !"%s" !1 ! !FirstDataSourceFile
# End of fields
ELOOP! !HasFV3Plus !!!1 !!HasFV3Plus
# read STC if in new format
EXPRE!$TFFREAD !!!!!!@Slice = []; dtsf = @DataStorageFormat; if any([1, 2] == dtsf), if dtsf == 1, tsnum = '1'; else, tsnum = ''; end, fmrf = fileparts($FILENAME); stcx = ''; if exist([fmrf '/' @Prefix tsnum '.stc'], 'file') == 2, stcx = '.stc'; else, if exist([fmrf '/' @Prefix tsnum '.STC'], 'file') == 2, stcx = '.STC'; end, end, if ~isempty(stcx), nov = @NrOfVolumes; nos = @NrOfSlices; rsx = @ResolutionX; rsy = @ResolutionY; stcsz = [rsx, rsy, nov, nos]; try, @Slice = struct; @Slice.STCData = []; switch(dtsf), case {1}, for tsc = 1:nos, stcf = sprintf('%s/%s%d%s', fmrf, @Prefix, tsc, stcx); @Slice(tsc).STCData = transio(stcf, 'ieee-le', 'uint16', 4, stcsz(1:3)); end, case {2}, @Slice.STCData = transio([fmrf '/' @Prefix stcx], 'ieee-le', 'uint16', 0, stcsz); end, catch, @Slice = []; warning('Error reading STC data.'); end, end, end
EXPRE!$TFFWRITE !!!!!!if ~any([1, 2] == @DataStorageFormat), warning('Invalid DataStorageFormat.'); elseif ~isempty(@Slice) && isstruct(@Slice) && isfield(@Slice, 'STCData'), [fmrf{1:3}] = fileparts($FILENAME); if any(fmrf{3}(2:end) == upper(fmrf{3}(2:end))), stcx = '.STC'; else, stcx = '.stc'; end, stctf = [fmrf{1} '/' @Prefix]; nov = @NrOfVolumes; nos = @NrOfSlices; rsx = @ResolutionX; rsy = @ResolutionY; stcsz = [rsx, rsy, nov, nos]; try, switch (@DataStorageFormat), case {1}, for tsc = 1:nos, stcf = sprintf('%s%d%s', stctf, tsc, stcx); stcd = @Slice(tsc).STCData; if istransio(stcd), tios = struct(stcd); if ~strcmpi(tios.FileName, stcf), if ~cpfile(tios.FileName, stcf, 1); error('FILE_COPY_ERROR'); end, @Slice(tsc).STCData = transio(stcf, 'ieee-le', 'uint16', 4, tios.DataDims); end, else, stci = fopen(stcf, 'w', 'ieee-le'); if stci < 1, error('FILE_OPEN_ERROR'); end, fwrite(stci, stcsz(1:2), 'uint16'); fwrite(stci, @Slice(tsc).STCData(:), 'uint16'); fclose(stci); end, end, case{2}, stcf = [stctf stcx]; stcd = @Slice.STCData; if istransio(stcd), tios = struct(stcd); if ~strcmpi(tios.FileName, stcf), if ~cpfile(tios.FileName, stcf, 1); error('FILE_COPY_ERROR'); end, @Slice.STCData = transio(stcf, 'ieee-le', 'uint16', 0, tios.DataDims); end, else, stci = fopen(stcf, 'w', 'ieee-le'); if stci < 1, error('FILE_OPEN_ERROR'); end, fwrite(stci, @Slice.STCData(:), 'uint16'); fclose(stci); end, end, end, end
# end of fields
EndListOfFields
NewFileCode:!
@FileVersion = 5;
@NrOfVolumes = 0;
@NrOfSlices = 30;
@NrOfSkippedVolumes = 0;
@Prefix = 'untitled-';
@DataStorageFormat = 2;
@TR = 2000;
@InterSliceTime = @TR / @NrOfSlices;
@TimeResolutionVerified = 0;
@TE = 30;
@SliceAcquisitionOrder = 0;
@SliceAcquisitionOrderVerified = 0;
@ResolutionX = 64;
@ResolutionY = 64;
@LoadAMRFile = '';
@ShowAMRFile = 0;
@ImageIndex = 0;
@LayoutNColumns = 6;
@LayoutNRows = fix(0.99 + @NrOfSlices / @LayoutNColumns);
@LayoutZoomLevel = 1;
@SegmentSize = 10;
@SegmentOffset = 0;
@NrOfLinkedProtocols = 1;
@ProtocolVersion = 2;
@ProtocolFile = '<none>';
@InplaneResolutionX = 3;
@InplaneResolutionY = 3;
@SliceThickness = 3;
@SliceGap = 1;
@VoxelResolutionVerified = 0;
@PosInfosVerified = 0;
@CoordinateSystem = 1;
@Slice1CenterX = 0;
@Slice1CenterY = 0;
@Slice1CenterZ = -(@NrOfSlices - 1) * (@SliceThickness + @SliceGap) / 2;
@SliceNCenterX = 0;
@SliceNCenterY = 0;
@SliceNCenterZ = (@NrOfSlices - 1) * (@SliceThickness + @SliceGap) / 2;
@RowDirX = 1;
@RowDirY = 0;
@RowDirZ = 0;
@ColDirX = 0;
@ColDirY = 1;
@ColDirZ = 0;
@NRows = @ResolutionX;
@NCols = @ResolutionY;
@FoVRows = @NRows * @InplaneResolutionX;
@FoVCols = @NCols * @InplaneResolutionY;
@GapThickness = @SliceGap;
@NrOfPastSpatialTransformations = 0;
@Trf = cell2struct(cell(0, 0, 5), {'NameOfSpatialTransformation', 'TypeOfSpatialTransformation', 'AppliedToFile', 'NrOfTransformationValues', 'TrfMatrix'}, 3);
@RadiologicalConvention = 'YES';
@FirstDataSourceFile = '<none>';
@Slice = [];
EndNewFileCode
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -