|
Doxygen Source Code Documentation
WriteBrik.m File Reference
Go to the source code of this file.
|
Functions |
M must be one or dimensional
the header | structure (see BrikInfo)%if BYTEORDER_STRING is not specified |
| if (nargin< 3) |
| errordlg (ErrMessage) |
end first check on Prefix | if (~isfield(Opt, 'Prefix')|isempty(Opt.Prefix)) |
end set format if not present | if (~isfield(Info,'FileFormat')|isempty(Info.FileFormat)) |
| if (isempty(Info)&size(M, 4)==1 &size(M, 3)==1) |
| elseif (strcmp(Info.FileFormat,'1D')) |
| if (size(M, 4)~=1|size(M, 3)~=1) |
end end | if (is1D) |
end end | if (isempty(Info)) |
default mode | if (isfield(Opt,'Slices')&~isempty(Opt.Slices)) |
default mode | if (length(Opt.Slices)~=1) |
end | if (Opt.Slices > 1) Opt1D.OverWrite |
| if (isempty(Ext)) |
| if (~isempty(Info.Extension_1D)) |
end check on options | if (~isfield(Opt, 'verbose')|isempty(Opt.verbose)) |
end | if (~isfield(Opt, 'NoCheck')|isempty(Opt.NoCheck)) |
end | if (Opt.verbose) |
end | fprintf (1,'%s verbose:Checking input data...', FuncName) |
end | if (~isfield(Opt, 'Scale')|isempty(Opt.Scale)) |
end | if (~isfield(Opt, 'View')|isempty(Opt.View)) |
end | if (~isempty(findstr('orig', lower(Opt.View)))) |
| elseif (~isempty(findstr('acpc', lower(Opt.View)))) |
| elseif (~isempty(findstr('tlrc', lower(Opt.View)))) |
end | if (~isfield(Opt, 'AppendHistory')|isempty(Opt.AppendHistory)) |
This check is done later on
before we write Slice | Frame (see below)%if(exist(FnameHEAD) |
unsqueeze the array | sizes (Keith's addition to fix writing time series, one slice at a time.Oct 01 04) if nd |
end | if (nd<=2) isVect |
end | if (isfield(Info, 'DATASET_DIMENSIONS')&length(Info.DATASET_DIMENSIONS)< 3 &length(Info.DATASET_DIMENSIONS) > 0) |
end | if ((~isfield(Info, 'DATASET_DIMENSIONS')|isempty(Info.DATASET_DIMENSIONS))&isVect) err |
end | if ((~isfield(Info, 'DATASET_RANK')|isempty(Info.DATASET_RANK))&isVect) err |
end | if (isfield(Info, 'DATASET_DIMENSIONS')&~isempty(Info.DATASET_DIMENSIONS)&~isVect)%if(N(1)~ |
end end setup DATASET_DIMENSIONS
and DATASET_RANK if needed | if (~isfield(Info, 'DATASET_DIMENSIONS')|isempty(Info.DATASET_DIMENSIONS)) |
end | if (~isfield(Info, 'DATASET_RANK')|isempty(Info.DATASET_RANK)) |
end any Mandatory variables
have now been check on the
Header content Check out the
values in Info | if (~Opt.NoCheck) |
end any Mandatory variables
have now been check on the
Header content Check out the
values in Info | fprintf (1,'HEAD Info structure...') |
| if (err) |
end end reshape to a vector | if (~isVect|nd==2) |
end Delete the let afni take
care of them | if (isfield(Info,'BRICK_STATS')) |
end Delete the let afni take
care of them | rmfield (Info,'BRICK_STATS') |
end | if (isfield(Info,'BRICK_FLOAT_FACS')) |
end | rmfield (Info,'BRICK_FLOAT_FACS') |
end figure out the ouput format | if (~isfield(Info, 'BRICK_TYPES')|isempty(Info.BRICK_TYPES)) |
end | if (~isfield(Info, 'BYTEORDER_STRING')|isempty(Info.BYTEORDER_STRING)) |
| if (ed_c(1)== 'L') ByteOrder |
| elseif (ed_c(1)== 'B') ByteOrder |
end else | if (~isempty(strmatch('MSB_FIRST', Info.BYTEORDER_STRING))) |
Big Endian else | if (~isempty(strmatch('LSB_FIRST', Info.BYTEORDER_STRING))) |
| if (length(itype) > 1) |
| if (~isfield(Opt,'Slices')|isempty(Opt.Slices)) |
| if (~isfield(Opt,'Frames')|isempty(Opt.Frames)) |
| if (Opt.Scale &isallslices &isallframes) |
| fprintf (1,'Scaling...') |
| for (j=1:1:Info.DATASET_RANK(2)) |
Info | BRICK_STATS (2.*(j-1)+1) |
Info | BRICK_STATS (2.*j) |
Info | BRICK_FLOAT_FACS (j) |
a bit lower than | if (Info.BRICK_FLOAT_FACS(j)==0) Info.BRICK_FLOAT_FACS(j) |
else | M (istrt:istp) |
open file for writing based
on the type specified in Info
if Opt | Slices (1) |
end | if (isallslices &isallframes) for frame |
end end write the file | fprintf (1,'Writing%s to disk...', FnameBRIK) |
if isallslices | fseek (fid, numpix *Info.DATASET_DIMENSIONS(3)*(frame-1)*Info.TypeBytes, 'bof') |
| fseek (fid, numpix *(slice-1+Info.DATASET_DIMENSIONS(3)*(frame-1))*Info.TypeBytes, 'bof') |
end end end end | if (cnt~=prod(size(M))) |
| fclose (fid) |
| if (filexist(FnameBRIK)==2) |
| delete (FnameBRIK) |
remove this annoying tset | message (some bug....)[err |
| if (Nlines >=2) |
end | if (tmp) |
| if (~isfield(Info,'HISTORY_NOTE')|isempty(Info.HISTORY_NOTE)) |
end call for the function
to write the header | fprintf (1,'Writing%s to disk...', FnameHEAD) |
end | fprintf (1,'Done.\n') |
Variables |
| function [err, ErrMessage, Info] |
M must be one or dimensional | Info = Info_1D(M) |
M must be one or dimensional
the header native is the default
format if BRICK_TYPES is not | specified |
M must be one or dimensional
the header native is the default
format if BRICK_TYPES is not
short is the default Info
can be empty for D files but
if you have one from BrikLoad
you should use it Opt an options
structure with the following | fields |
M must be one or dimensional
the header native is the default
format if BRICK_TYPES is not
short is the default Info
can be empty for D files but
if you have one from BrikLoad
you should use it Opt an options
structure with the following
Most of the options are irrelevant
for D formats | Scale = 0 |
| FUNCTION_VERSION = 'V2.0' |
Debug Flag | DBG = 1 |
initailize return variables | err = 1 |
| ErrMessage = '' |
| return |
end set format if not present
Info | FileFormat = 'BRIK' |
end is this a D file | is1D = 0 |
end Opt1D | OverWrite = 'n' |
end end Opt1D | Space = 't' |
Opt1D | Fast = 'y' |
Opt1D | verbose = 0 |
| Ext = sprintf('%s', Info.Extension_1D) |
end end | FullName = sprintf('%s%s', Name, Ext) |
end Info | Extension_1D = sprintf('%s', Ext) |
Info | RootName = sprintf('%s', Name) |
end Opt | NoCheck = 0 |
end Opt | View = 'orig' |
end Opt | Views = '+orig' |
end Opt | AppendHistory = 1 |
end form the flename based
on the stuff in Opt | Prefix |
end form the flename based
on the stuff in Opt just use
the option | Fname = sprintf('%s%s', Opt.Prefix, Opt.Views) |
| FnameHEAD = sprintf('%s%s.HEAD', Opt.Prefix, Opt.Views) |
| FnameBRIK = sprintf('%s%s.BRIK', Opt.Prefix, Opt.Views) |
end make sure there is no
clash in input data is M a
D or D | N = zeros(1,4) |
| nd = size(M) ndims(M) |
else | isVect = 0 |
end end | OK |
end end setup DATASET_DIMENSIONS
and DATASET_RANK if needed
Info | DATASET_DIMENSIONS = N(1:3) |
end Info | DATASET_RANK = [3 N(4)] |
end any Mandatory variables
have now been | set |
| end [err, ErrMessage, Info] = CheckBrikHEAD(Info) |
end end reshape to a vector | M = reshape(M, prod(N), 1) |
end Delete the | Brick_Stats |
end figure out the ouput format | B_type = 1 |
end set the order based on the | machine |
end set the order based on
the used to | be |
prior to | Feb [c_c, mx_c, ed_c] = computer |
Little Endian Info | BYTEORDER_STRING = 'LSB_FIRST' |
end else | ByteOrder = 'ieee-be' |
end end end | itype = unique(B_type) |
end switch case | typestr = 'ubit8' |
end figure out if scaling
is required | allslices = 1:Info.DATASET_DIMENSIONS(3) |
Opt | Slices = allslices |
end | isallslices = all(ismember(allslices,Opt.Slices)) |
| allframes = 1:Info.DATASET_RANK(2) |
Opt | Frames = allframes |
end | isallframes = all(ismember(allframes,Opt.Frames)) |
Info | BRICK_FLOAT_FACS = zeros(1,Info.DATASET_RANK(2)) |
end | NperBrik = Info.DATASET_DIMENSIONS(1) .* Info.DATASET_DIMENSIONS(2) .* Info.DATASET_DIMENSIONS(3) |
| istrt = 1+ (j-1).*NperBrik |
| istp = istrt + NperBrik - 1 |
end end end | numpix = Info.DATASET_DIMENSIONS(1)*Info.DATASET_DIMENSIONS(2) |
| numslices = length(Opt.Slices) |
| numframes = length(Opt.Frames) |
end end | else [fid, mess] = fopen (FnameBRIK, 'r+', ByteOrder) |
end if isallslices &isallframes | cnt = fwrite(fid, M, typestr) |
for | k |
else for | j |
if Opt OptHist | AFNI_Format = 1 |
if | isunix [tmp, OptHist.PerSig] = unix('whoami') |
remove this annoying tset | snl |
remove this annoying tset | Nlines = GetNextLine(OptHist.PerSig, 2) |
end OptHist | PerSig = sprintf('DunnoWho') |
Info | HISTORY_NOTE = '' |
Function Documentation
Info BRICK_FLOAT_FACS |
( |
j |
|
) |
|
|
Info BRICK_STATS |
( |
2.* |
j |
) |
|
|
Info BRICK_STATS |
( |
2.*(j-1)+ |
1 |
) |
|
|
elseif |
( |
ed_c(1) |
= = 'B' |
) |
|
|
elseif |
( |
~ |
isempty(findstr('tlrc', lower(Opt.View))) |
) |
|
|
elseif |
( |
~ |
isempty(findstr('acpc', lower(Opt.View))) |
) |
|
|
for |
( |
j |
= 1:1:Info.DATASET_RANK(2) |
) |
|
|
end fprintf |
( |
1 |
, |
|
|
'Done.\n' |
|
|
) |
|
|
fprintf |
( |
1 |
, |
|
|
'Scaling...' |
|
|
) |
|
|
This check is done later on before we write Slice Frame |
( |
see |
below |
) |
|
|
if |
( |
~ |
isfield(Info,'HISTORY_NOTE')|isempty(Info.HISTORY_NOTE) |
) |
|
|
a bit lower than if |
( |
Info. |
BRICK_FLOAT_FACS(j) = =0 |
) |
|
|
if |
( |
~ |
isfield(Opt,'Frames')|isempty(Opt.Frames) |
) |
|
|
if |
( |
~ |
isfield(Opt,'Slices')|isempty(Opt.Slices) |
) |
|
|
Big Endian else if |
( |
~ |
isempty(strmatch('LSB_FIRST', Info.BYTEORDER_STRING)) |
) |
|
|
end else if |
( |
~ |
isempty(strmatch('MSB_FIRST', Info.BYTEORDER_STRING)) |
) |
|
|
end if |
( |
~ |
isfield(Info, 'BYTEORDER_STRING')|isempty(Info.BYTEORDER_STRING) |
) |
|
|
end figure out the ouput format if |
( |
~ |
isfield(Info, 'BRICK_TYPES')|isempty(Info.BRICK_TYPES) |
) |
|
|
end if |
( |
isfield(Info,'BRICK_FLOAT_FACS') |
|
) |
|
|
end Delete the let afni take care of them if |
( |
isfield(Info,'BRICK_STATS') |
|
) |
|
|
end if |
( |
~ |
isfield(Info, 'DATASET_RANK')|isempty(Info.DATASET_RANK) |
) |
|
|
end if |
( |
(~isfield(Info, 'DATASET_RANK')|isempty(Info.DATASET_RANK))& |
isVect |
) |
|
|
end if |
( |
~ |
isfield(Opt, 'AppendHistory')|isempty(Opt.AppendHistory) |
) |
|
|
end if |
( |
~ |
isempty(findstr('orig', lower(Opt.View))) |
) |
|
|
end if |
( |
~ |
isfield(Opt, 'View')|isempty(Opt.View) |
) |
|
|
end if |
( |
~ |
isfield(Opt, 'Scale')|isempty(Opt.Scale) |
) |
|
|
end if |
( |
~ |
isfield(Opt, 'NoCheck')|isempty(Opt.NoCheck) |
) |
|
|
end check on options if |
( |
~ |
isfield(Opt, 'verbose')|isempty(Opt.verbose) |
) |
|
|
if |
( |
~ |
isempty(Info.Extension_1D) |
) |
|
|
if |
( |
isempty(Ext) |
= = 1 |
) |
|
|
end if |
( |
Opt. |
Slices, |
|
|
1 |
|
|
) |
|
|
default mode if |
( |
length(Opt.Slices)~ |
= 1 |
) |
|
|
default mode if |
( |
isfield(Opt,'Slices')&~isempty(Opt.Slices) |
|
) |
|
|
if |
( |
size(M, 4)~ |
= 1 | size(M,3) ~= 1 |
) |
|
|
if |
( |
isempty(Info)&size(M, 4) |
= = 1 & size(M,3) == 1 |
) |
|
|
end set format if not present if |
( |
~ |
isfield(Info,'FileFormat')|isempty(Info.FileFormat) |
) |
|
|
end first check on Prefix if |
( |
~ |
isfield(Opt, 'Prefix')|isempty(Opt.Prefix) |
) |
|
|
remove this annoying tset message |
( |
some |
bug.... |
) |
|
|
end rmfield |
( |
Info |
, |
|
|
'BRICK_FLOAT_FACS' |
|
|
) |
|
|
end Delete the let afni take care of them rmfield |
( |
Info |
, |
|
|
'BRICK_STATS' |
|
|
) |
|
|
unsqueeze the array sizes |
( |
Keith's addition to fix writing time |
series, |
|
|
one slice at a time.Oct 01 |
04 |
|
) |
|
|
M must be one or dimensional the header structure |
( |
see |
BrikInfo |
) |
|
|
Variable Documentation
Info BRICK_FLOAT_FACS = zeros(1,Info.DATASET_RANK(2)) |
|
prior to Feb[c_c, mx_c, ed_c] = computer |
|
|
Definition at line 194 of file WriteBrik.m.
Referenced by AFNI_register_nD_func_init(), AFNI_register_nD_function(), cds(), copy_data(), dim_finish(), hilbertdelay_V2(), HISTO_main(), make_empty_data_element(), mri_medianfilter(), ncinquire(), ncvarinq(), NI_copy_struct(), NI_dataset_transpose(), NI_free_struct(), NI_pointto_struct(), NI_register_struct(), NI_set_dimen(), NI_unregister_struct(), plotpak_setdsh(), PLUTO_commandstring(), prolog(), setbound(), setdsh_(), setlin_(), SUMA_Householder(), SUMA_input(), SUMA_isNumString(), SUMA_ScaleToMap_Interactive(), SUMA_StringToNum(), THD_check_idcodes(), WINsorize(), wr_char_len(), write_char_init(), write_namelists(), and x_rsne(). |
|
Referenced by initialize(), ISQ_disp_options(), MCW_val_bbox(), qh_gethash(), qh_maxmin(), qh_point_add(), qh_setcheck(), qh_setcompact(), qh_setcopy(), qh_setdel(), qh_setdellast(), qh_setdelnth(), qh_setdelnthsorted(), qh_setdelsorted(), qh_setduplicate(), qh_setin(), qh_setindex(), qh_setlarger(), qh_setlast(), qh_setnew(), qh_setnew_delnthsorted(), qh_setprint(), qh_setreplace(), qh_setsize(), qh_settempfree(), qh_settempfree_all(), qh_settemppush(), qh_settruncate(), qh_setunique(), qh_setzero(), r_wt_cb_SB_toggle(), SetResize(), and SUMA_cb_ColPlane_Delete(). |
remove this annoying tset snl |
|
|