Differences between revisions 1 and 11 (spanning 10 versions)
Revision 1 as of 2006-03-01 11:24:12
Size: 2883
Editor: KevinTeich
Comment:
Revision 11 as of 2011-09-14 11:15:31
Size: 1252
Comment:
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. == VTK cvs commit Guidelines and Coding Standards ==
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.
VTK has excellent [[http://www.vtk.org/Wiki/VTK_cvs_commit_Guidelines|cvs commit guidelines]] and [[http://www.vtk.org/Wiki/VTK_Coding_Standards|coding standards]], the following of which is highly recommended when working with the FreeSurfer code.
Line 12: Line 11:
{{{
MRI *MRIallocHeader(width, height, depth, type)
}}}
== Code format style ==
Line 16: Line 13:
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.
 * Consistent usage of either ANSI-style or GNU-style braces.
 * Do not use tabs. Setup your editor to convert tabs to spaces.
 * 2 spaces per indent (tab).
 * Do not exceed 80 characters per line.
 * Delete trailing whitespace from end of line.
Line 21: Line 19:
{{{
int MRIinitHeader(MRI *mri)
}}}
The script {{{attachment:~nicks/bin/do-astyle-onefile}}} will reformat a file to these conventions, making use of the [[http://astyle.sourceforge.net/|'astyle' utility]].
Line 25: Line 21:
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 Cheat Sheet ==
Line 30: Line 23:
{{{
MRI * MRIalloc(int width, int height, int depth, int type)
MRI * MRIallocSequence(int width, int height, int depth, int type, int nframes)
}}}
[[DevelopersGuide/CodingGuide/MRICheatSheet|MRI cheat sheet]]
Line 35: Line 25:
Will alloc pixel data with the given size and type. Ever wonder when you should use MRIcopy() vs MRIclone()? DougGreve has drawn up a little cheat sheet for some of these MRI functions.
Line 37: Line 27:
{{{
int MRIcopyHeader(MRI *mri_src, MRI *mri_dst)
}}}
== Naming Conventions ==
Line 41: Line 29:
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).

[[DevelopersGuide/CodingGuide/NamingConventions|A page of naming convention suggestions.]]

Coding Guide

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

VTK cvs commit Guidelines and Coding Standards

VTK has excellent cvs commit guidelines and coding standards, the following of which is highly recommended when working with the FreeSurfer code.

Code format style

  • Consistent usage of either ANSI-style or GNU-style braces.
  • Do not use tabs. Setup your editor to convert tabs to spaces.
  • 2 spaces per indent (tab).
  • Do not exceed 80 characters per line.
  • Delete trailing whitespace from end of line.

The script attachment:~nicks/bin/do-astyle-onefile will reformat a file to these conventions, making use of the 'astyle' utility.

MRI Cheat Sheet

MRI cheat sheet

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

Naming Conventions

A page of naming convention suggestions.

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