|
Size: 2666
Comment: Added DICOM position tag information.
|
Size: 3975
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| #pragma section-numbers on | #acl LcnGroup:read,write,delete,revert All:read |
| Line 3: | Line 3: |
| = Index = | = FreeSurfer Dev Guide = |
| Line 5: | Line 5: |
| [[Navigation(children)]] [[TableOfContents]] |
* Visit the BuildGuide for instructions on building and installing freesurfer manually. * Visit the GitHub page for an introduction to the github workflow. * Visit the GitAnnex page for detailed instructions on using git annex for storing and retrieving large data files in the repository. |
| Line 8: | Line 9: |
| = File Format Information = | == File Size Limitations == |
| Line 10: | Line 11: |
| == DICOM == === DICOM Resources === [http://medical.nema.org/dicom/2003.html DICOM specification] [[BR]] [http://dclunie.com/medical-image-faq/html/part8.html DICOM informtion sources] |
Any files larger than 50MB should be stored in the Git Annex, following the instructions above, and properly linked to your utility. |
| Line 15: | Line 13: |
| === DICOM Position/Orientation Information === DICOM uses a "Tag" to retrieve "Attribute Name" information. The documentation can be found in the [http://medical.nema.org/dicom/2003.html DICOM specification]. The image position and the image orientation section is in Part 3:Information Object Definition, C.7.6.1.1.1 and C.7.6.2.1.1. |
== Adding a New C Program == |
| Line 18: | Line 15: |
| The DICOM coordinate system is the LPS (left-posterior-superior), meanwhile the RAS coordinate system is right-anterior-superior. | If you'd like to add a new program to the tree, you should create a new subdirectory with the title of your tool. As an example, let's create a new c++ program called `mri_process`. First, we'll create a top-level subdirectory that contains our new c++ file and an empty `CMakeLists.txt` file: |
| Line 20: | Line 17: |
| The tag for the image position is (0x20, 0x32) and returns the x, y, z position of the upper left-hand corner of the image (the center of the first voxel). | {{{ freesurfer/ mri_process/ CMakeLists.txt mri_process.cpp }}} |
| Line 22: | Line 24: |
| The tag for the image orientation is (0x20, 0x37) and it returns the direction cosines of the first row and the first column with respect to the patient: first the value for the row x, y, z and then the value for the column x, y, z. For example, I get the string of the form "0.00000\\1.00000\\0.00000\\0.00000\\0.00000\\-1.00000". | In order to configure our new code, we should add the following to the empty `CMakeLists.txt` file. |
| Line 24: | Line 26: |
| The tag for the patient orientation is (0x20, 0x20) and it returns the position relative to the image plane by two characters with respect to the positive row axis (left to right) and the positive column axis (top to bottom). The character used are A(anterior), P(posterior), R(right), L(left), H(head), and F(foot). For example, the string I got was "P\\F" (posterior, foot). | {{{ project(mri_process) |
| Line 26: | Line 29: |
| include_directories(${FS_INCLUDE_DIRS}) | |
| Line 27: | Line 31: |
| == Medical Image Format FAQ == [http://www.dclunie.com/medical-image-faq/html Medical Image Format FAQ] |
add_executable(mri_process mri_process.cpp) target_link_libraries(mri_process utils) |
| Line 30: | Line 34: |
| = CVS Checkout = | install(TARGETS mri_process DESTINATION bin) }}} |
| Line 32: | Line 37: |
| There are several ways to do: pserver, ext, kserver, gserver. See, e.g. Chapter 2 of [http://cvsbook.red-bean.com/cvsbook.html Open Source Development with CVS] by K. Fogel and M. Bar (2nd Edition, Coriolis Group, 2001). | This will compile `mri_process.cpp`, link it against the `utils` freesurfer library, and copy the executable to the `$FREESURFER_HOME/bin` directory during install. To include this subdirectory in the main freesurfer build, make sure to modify the top-level `CMakeLists.txt` by adding `mri_process` to the long list of included directories at the bottom of the file. Now, after reconfiguring your build, you can run `make` in the `mri_process` directory of your build tree to successfully compile the new program. If you're having trouble configuring and building freesurfer, be sure to visit the BuildGuide for step-by-step instructions. |
| Line 34: | Line 39: |
| '''pserver''' | == Adding a New Python Program == |
| Line 36: | Line 41: |
| `cvs -d :pserver:tosa@cvs.foobar.com:/space/repo/1/dev login` | Adding a new python program is similar to adding a new c++ program, with an additional step of creating a bash wrapper to be installed in `$FREESURFER_HOME/bin`. * Note: Make sure all paths in the Bash wrapper that reference files in the FreeSurfer file tree are defined relative to `$FREESURFER_HOME`, to ensure they are found regardless of the install location |
| Line 38: | Line 44: |
| where username is "`tosa`" on the server "`cvs.foobar.com`". The cvs depository is `/space/repo/1/dev`. You get asked about the password. Once you stored your authentication in `.cvspass` file, you can run other CVS commands using a similar way. | As an example, let’s add a program called `mri_process` to the FreeSurfer tree, where the main functionality is in a python script called `mri_process.py`, and has a dependency on a model called `process_model.h5`. |
| Line 40: | Line 46: |
| `cvs -d :pserver:tosa@cvs.foobar.com:/space/repo/1/dev co dev` | First, we’ll create a directory containing the scripts, dependencies, and `CMakeLists.txt`: |
| Line 42: | Line 48: |
| which checkout the entire directory `dev` into the current directory. | {{{ freesurfer/ mri_process/ CMakeLists.txt mri_process.sh # shell wrapper to install in bin/ process_model.h5 # model dependency stored in the annex python/ # dir containing the python code mri_process.py # python script called by shell wrapper }}} |
| Line 44: | Line 58: |
| '''ext''' | Now we’ll need to populate the empty `CMakeLists.txt` file. We need to achieve the following in this file: 1. Give the utility a project name 2. Link the python scripts to the location they are referenced by the Bash wrapper 3. Install the wrapper script into `$FREESURFER_HOME/bin` 4. Link any models to the proper location to be accessible to the python code |
| Line 46: | Line 64: |
| `export CVS_RSH=ssh` [[BR]] `cvs -d :ext:tosa@cvs.foobar.com:/space/repo/1/dev co dev` |
An example `CMakeLists.txt`: {{{ project(mri_process) install_symlinks(python/mri_process.py TYPE files DESTINATION python/scripts) install_configured(mri_process.sh DESTINATION bin) install_symlinks(process_model.h5 TYPE files DESTINATION models) }}} |
| Line 49: | Line 72: |
| Note that even though CVS_RSH, we use `ssh`, which is a secure shell | Finally, we need to add this directory to the list of included directories in the `CMakeLists.txt` located at the top level of the FreeSurfer file tree. To add your new utility to your build of FreeSurfer, reconfigure your build, and run make in the `mri_process` directory. You can also rebuild all of FreeSurfer with your new utility if needed. More information on building Freesurfer is located in the BuildGuide. |
FreeSurfer Dev Guide
Visit the BuildGuide for instructions on building and installing freesurfer manually.
Visit the GitHub page for an introduction to the github workflow.
Visit the GitAnnex page for detailed instructions on using git annex for storing and retrieving large data files in the repository.
File Size Limitations
Any files larger than 50MB should be stored in the Git Annex, following the instructions above, and properly linked to your utility.
Adding a New C Program
If you'd like to add a new program to the tree, you should create a new subdirectory with the title of your tool. As an example, let's create a new c++ program called mri_process. First, we'll create a top-level subdirectory that contains our new c++ file and an empty CMakeLists.txt file:
freesurfer/
mri_process/
CMakeLists.txt
mri_process.cppIn order to configure our new code, we should add the following to the empty CMakeLists.txt file.
project(mri_process)
include_directories(${FS_INCLUDE_DIRS})
add_executable(mri_process mri_process.cpp)
target_link_libraries(mri_process utils)
install(TARGETS mri_process DESTINATION bin)This will compile mri_process.cpp, link it against the utils freesurfer library, and copy the executable to the $FREESURFER_HOME/bin directory during install. To include this subdirectory in the main freesurfer build, make sure to modify the top-level CMakeLists.txt by adding mri_process to the long list of included directories at the bottom of the file. Now, after reconfiguring your build, you can run make in the mri_process directory of your build tree to successfully compile the new program. If you're having trouble configuring and building freesurfer, be sure to visit the BuildGuide for step-by-step instructions.
Adding a New Python Program
Adding a new python program is similar to adding a new c++ program, with an additional step of creating a bash wrapper to be installed in $FREESURFER_HOME/bin.
Note: Make sure all paths in the Bash wrapper that reference files in the FreeSurfer file tree are defined relative to $FREESURFER_HOME, to ensure they are found regardless of the install location
As an example, let’s add a program called mri_process to the FreeSurfer tree, where the main functionality is in a python script called mri_process.py, and has a dependency on a model called process_model.h5.
First, we’ll create a directory containing the scripts, dependencies, and CMakeLists.txt:
freesurfer/
mri_process/
CMakeLists.txt
mri_process.sh # shell wrapper to install in bin/
process_model.h5 # model dependency stored in the annex
python/ # dir containing the python code
mri_process.py # python script called by shell wrapperNow we’ll need to populate the empty CMakeLists.txt file. We need to achieve the following in this file:
- Give the utility a project name
- Link the python scripts to the location they are referenced by the Bash wrapper
Install the wrapper script into $FREESURFER_HOME/bin
- Link any models to the proper location to be accessible to the python code
An example CMakeLists.txt:
project(mri_process) install_symlinks(python/mri_process.py TYPE files DESTINATION python/scripts) install_configured(mri_process.sh DESTINATION bin) install_symlinks(process_model.h5 TYPE files DESTINATION models)
Finally, we need to add this directory to the list of included directories in the CMakeLists.txt located at the top level of the FreeSurfer file tree. To add your new utility to your build of FreeSurfer, reconfigure your build, and run make in the mri_process directory. You can also rebuild all of FreeSurfer with your new utility if needed. More information on building Freesurfer is located in the BuildGuide.
