Differences between revisions 1 and 2
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
[TableOfContents] [[TableOfContents]]
Line 5: Line 5:
== MRI cheat sheet == This page is a loose collection of various coding guides and tips for FreeSurfer programmers.
Line 7: Line 7:
From DougGreve. == MRI Cheat Sheet ==
Line 9: Line 9:
Ever wonder when you should use MRIcopy() vs MRIclone()? I've drawn up a
little cheat sheet (attached) for some of these MRI functions.
[wiki:Self:DevelopersGuide/CodingGuide/MRICheatSheet MRI cheat sheet]
Line 12: Line 11:
{{{
MRI *MRIallocHeader(width, height, depth, type)
}}}

Allocs header space. Sets geometry info to that of a conformed
volume. Sets voxel sizes to 1. Direction cosines set to dcx = [-1 0
0], dcy = [0 0 -1], dcz = [0 1 0]. c_ras=0, ras_good=0. nframes=1. No
pixel data or pointers to pixel data are alloced.

{{{
int MRIinitHeader(MRI *mri)
}}}

Sets geometry info to that of a conformed volume like
MRIallocHeader(). Sets voxel sizes to 1. Direction cosines set to dcx
= [-1 0 0], dcy = [0 0 -1], dcz = [0 1 0]. c_ras=0. But unlike
MRIallocHeader(), ras_good=1.

{{{
MRI * MRIalloc(int width, int height, int depth, int type)
MRI * MRIallocSequence(int width, int height, int depth, int type, int nframes)
}}}

Will alloc pixel data with the given size and type.

{{{
int MRIcopyHeader(MRI *mri_src, MRI *mri_dst)
}}}

Will copy voxel resoution, geometry, tranforms, names, paths, acq
parameters. Will not copy width, height, depth, nframes, or precision
type.

{{{
MRI *MRIclone(MRI *mri_src, MRI *mri_dst)
}}}

If destination mri is NULL, then allocs same size and
precision type as the src. Always copies header from source to dest
with MRIcopyHeader(). Does not copy pixel data.

{{{
MRIcloneBySpace(MRI *mri_src, int nframes)
}}}

Allocs same type and size as source but with given number of
frames. Copies source header with MRIcopyHeader(). Does not copy pixel
data.

{{{
MRIcopy(MRI *mri_src, MRI *mri_dst)
}}}

If dest is NULL, then dest is alloced with the same type and size as
the source. Source header is copied to dest with MRIcopyHeader(). If
dest does not have pixel space alloed, then just returns (basically
just doing MRIcopyHeader. Otherwise copies pixel data. Note: if the
dest and the source point to the same place, then just returns dest
immediately. Handles source and dest being different precision types.

{{{
MRI *MRISeqchangeType(MRI *vol, int dest_type, float f_low,
                      float f_high, int no_scale_option_flag)
}}}

MRISeqchangeType() - changes the data type for a 3D or 4D volume.
This simply changes the volume dimensions so that it appears to be a
3D volume, then calls MRIchangeType(), and then resets the dimensions
to their original values. The values of the volume can be rescaled
between f_low and f_high.

{{{
int MRIdump(MRI *mri, FILE *fp);
}}}

Dumps header to file pointer.

{{{
int MRIdumpBuffer(MRI *mri, FILE *fp)
}}}

Dump the non-zero elements of an MRI buffer to a file pointer. Each
line is something like [c][r][s] value. Only works on uchars and
floats. Does not print multiple frames (naturally).

Ever wonder when you should use MRIcopy() vs MRIclone()? DougGreve has drawn up a little cheat sheet (attached) for some of these MRI functions.

Coding Guide

TableOfContents

This page is a loose collection of various coding guides and tips for FreeSurfer programmers.

MRI Cheat Sheet

[wiki:DevelopersGuide/CodingGuide/MRICheatSheet MRI cheat sheet]

Ever wonder when you should use MRIcopy() vs MRIclone()? DougGreve has drawn up a little cheat sheet (attached) for some of these MRI functions.

DevelopersGuide/CodingGuide (last edited 2011-09-14 11:16:08 by NickSchmansky)