|
Size: 10353
Comment:
|
Size: 6947
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 2: | Line 2: |
[[Navigation(children)]] |
#acl WikiUserGroup:read,write,delete,revert All:read |
| Line 7: | Line 6: |
| [[TableOfContents]] | <<TableOfContents>> |
| Line 9: | Line 8: |
| === Medical Image Format FAQ === [http://www.dclunie.com/medical-image-faq/html Medical Image Format FAQ] |
This page is targeted at Martinos Center users who wish develop within the Freesurfer code base and possibly contribute changes. Martinos and non-Martinos users who simply want to clone the repo and build on their home machine, but dont plan on contributing changes, should consult the [[http://surfer.nmr.mgh.harvard.edu/fswiki/freesurfer_linux_developers_page|read-only git repo]]. Lastly, users who just want access to the code can clone directly from the official freesurfer github page: |
| Line 12: | Line 10: |
| === CVS Checkout === | https://github.com/freesurfer/freesurfer |
| Line 14: | Line 12: |
| You can checkout the FreeSurfer source code from the NMR center using local CVS access or remotely by using SSH as the CVS remote connection method. | === Getting the Source Code === |
| Line 16: | Line 14: |
| ==== Local CVS Access ==== | In order to contribute changes to Freesurfer, a specific setup procedure needs to be followed where a users forks the Freesurfer github repository, clones the fork, and submit pull requests. This is described in detail here: |
| Line 18: | Line 16: |
| The CVS repository is /space/repo/1/dev. Use this as your CVSROOT. You can either set it as an environment variable: | https://surfer.nmr.mgh.harvard.edu/fswiki/Freesurfer_github |
| Line 20: | Line 18: |
| {{{setenv CVSROOT /space/repo/1/dev}}} or specify it in the checkout command with the -d option. Note that the CVS root is cached in a CVS checkout directory, so if you choose to use the -d method, you will only have to do it once during your first checkout. Check out the code with the CVS checkout command. The archive name is dev. {{{cvs checkout dev}}} or {{{cvs -d /space/repo/1/dev checkout dev}}} This will copy the entire archive to your directory, creating a directory called dev/. Now set up your environment to use this dev directory by running the script in dev/: {{{cd dev source set_dev_env_to_here.csh}}} ==== Remote CVS Access ==== Tell CVS to use SSH to access the archive by setting the following environment variable: {{{setenv CVS_RSH ssh}}} Use the following string as your CVS root: {{{:ext:USER@MACHINE.nmr.mgh.harvard.edu:/space/repo/1/dev}}} Where USER is your username and MACHINE is one of the NMR machines visible to the outside, i.e. gate, entry, or door. Then use the CVS commands normally. Note that using this method makes an SSH connection for every CVS command, and you will be required to enter your password every time. You may want to look into a utility to automatically authenticate SSH connections, such as SSH agent. |
|
| Line 55: | Line 21: |
| ==== Required reading ===== | Once the source code has been cloned the next step is building it. The steps required to building the Freesurfer code base are described below: |
| Line 57: | Line 23: |
| Please check out the following files in the dev/ archive first: {{{README-compiling.txt, README-releasing.txt}}} | ==== Setup Configure ==== |
| Line 59: | Line 25: |
| ==== Adding a new binary to the tree ==== Assuming that you have a source file {{{MYPROG.c}}} that compiles into MYPROG and want to add it to the FreeSurfer tree: 1) Make the directory in dev and copy the source file there. Name the directory MYPROG and the source file {{{MYPROG.c}}}. |
It is necessary to run a pre-configure script, to create the platform specific tools required by configure (execute in the {{{freesurfer}}} directory created by {{{git clone}}}). This script runs a set of commands (aclocal, libtoolize, automake v1.9.6, autoconf v2.59) that creates the platform specific files for configure and puts them in the 'fsdev/config' directory. |
| Line 66: | Line 28: |
| mkdir dev/MYPROG cp MYPROG.c dev/MYPROG |
./setup_configure |
| Line 70: | Line 31: |
| 2) Tell the autotools to build your program when you type {{{make}}} from the top dir. | ==== Configure ==== |
| Line 72: | Line 33: |
| a) Modify {{{dev/configure.in}}} to add {{{MYPROG/Makefile}}} to the list at the end of the file in the definition of {{{AC_OUTPUT}}}. Be sure to add a backslash at the end of line: | Now you need to configure your building parameters for your machine by running the {{{configure}}} script. Users at the Martinos Center should for the most part be fine with the default settings, but the {{{configure}}} script does accept many options for pointing to specific libraries and other build specific parameters. One exception is if a user wants to perform a local installation of !FreeSurfer, he/she should use the {{{--prefix}}} flag. Type {{{./configure --help}}} for a full list of options. For example: |
| Line 75: | Line 36: |
| AC_OUTPUT( \ ... other files ... MYPROG/Makefile \ ) |
## Default configuration ./configure ## Specify an installation location ./configure --prefix=~/freesurfer_install_dir ## See all possible options ./configure --help |
| Line 81: | Line 46: |
| b) Modify {{{dev/Makefile.am}}} to add {{{MYPROG}}} to the {{{SUBDIRS}}} definition. (You can also alternatively it to the end of {{{MRISUBDIRS}}} or {{{MRISSUBDIRS}}} if more appropriate.) | Freesurfer builds against the following set of open-sourced libraries, which are installed under the {{{/usr/pubsw/packages}}} directory on all NMR computers: || Package || Version || || Package || Version || || CUDA || v5.0.35-rh5 || || ANN || v1.1 || || tiffjpegglut || v3.6, v6b, v3.7 || || itk || v3.16 || || VTK || v5.6 || || VXL || v1.14 || || MNI || v1.5 || || tcltktixblt || v8.4, v8.4, v8.1, v2.4z || || KWWWidgets || CVS checkout || || Qt || v4.7 || || wxWidgets || v2.8 || || cppunit || v1.10 || || xawplus || v3.1 || || petsc || v2.3 || All these packages will be found by default by the {{{./configure}}} script. But there are options to specify where certain packages exists if a user wishes to build against a different version of one of the open-source libraries. For example: |
| Line 84: | Line 61: |
| SUBDIRS= ... other directories ... MYPROG | ## Specify a specific version of qt ./configure --with-qt=/usr/pubsw/packages/qt/4.8.5/bin |
| Line 87: | Line 65: |
| c) Copy {{{dev/dummy/Makefile.am}}} into {{{MYPROG/}}} and customize it, replacing 'dummy' with 'MYPROG'. Be sure to change: | ==== Compile ==== You can now run 'make' to build the all individual programs in the !FreeSurfer source tree. Binaries will automatically be placed in their individual subdirectories. {{{ make -j 4 }}} ''Handy hint: the -j 4 option to make tells it to run four simultaneous make processes, which, if building on a multi-processor machine, can speed-up the build.'' If you want to compile just one binary at a time, for example, if you are developing an app, than {{{cd}}} to the directory of the program you want and use 'make' to compile it: {{{ cd mri_info make }}} This creates mri_info in the mri_info/ directory. However, be aware the many program depends on the existence of libraries having already been build like libutils. Therefore users will need to build a few of the library directories first (e.g. utils, fsgdf, xml2, etc). ==== Install ==== To initial a local installation, type 'make install' from the top level directory: {{{ make install }}} This will create a local Freesurfer installation in the directory as specified by the {{{--prefix}}} option to {{{configure}}} script (see above). Note that if you do not specify this location, it will try to install to /usr/local, which will probably require root access. The first time you run 'make install', it will take a while to copy all the big data files to the new installation. Subsequent 'make installs' will only copy the changed files. If you only want to install a single binary, run 'make install' from a subdirectory. For example, running 'make install' from the {{{mri_convert}}} directory will copy the {{{mri_convert}}} binary to the proper locations. Running 'make install' from scripts/ will copy all the necessary scripts to the right location. === Adding a new binary to the tree === For this example we will assume you want to create a program called 'MYPROG' and want to add it to the !FreeSurfer tree: 1) Make a directory called {{{MYPROG}}} under the {{{freesurfer}}} directory, and put your source code there. In the simplest case you will have a single source code file called {{{MYPROG.c}}}. {{{ ## Create the MYPROG directory and 'cd' into it mkdir MYPROG cd MYPROG ## The MYPROG.c file goes here }}} 2) Copy {{{freesurfer/dummy/Makefile.am}}} into {{{MYPROG/}}} and customize it, replacing 'dummy' with 'MYPROG'. Also delete the notes that are there. Be sure to change: |
| Line 93: | Line 112: |
| d) Copy in the additional testing file {{{dev/dummy/myown.c}}}. You can customize it for your test program later. | |
| Line 95: | Line 113: |
| 3) Run {{{automake}}} from {{{dev/}}}. You should get no errors. If you do, make sure you followed the above instructions properly. Also try the AutoconfTroubleshooting page. Verify that this stepped work by checking if {{{MYPROG/Makefile.in}}} was created. | 3) Modify {{{configure.in}}} to add {{{MYPROG/Makefile}}} to the list of files in the definition of {{{AC_OUTPUT}}} (these are in roughly alphabetical order). |
| Line 97: | Line 115: |
| 4) Run {{{autoconf}}} to generate a new {{{configure}}} script that now includes your new MYPROG directory. 5) Run {{{./configure}}} with the parameters you previously used. To check these out, run {{{head config.log}}} from {{{dev/}}}. The output should include the {{{./configure}}} line you used. Copy it, but leave out the {{{--no-create --no-recursion}}} options if present. |
|
| Line 102: | Line 117: |
| [dev/]$ head config.log This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. |
|
| Line 106: | Line 118: |
| It was created by Freesurfer configure 0.1, which was generated by GNU Autoconf 2.57. Invocation command line was |
## configure.in ## |
| Line 109: | Line 120: |
| $ ./configure --with-mni-dir=/usr/pubsw/packages/mni/current --prefix=/home/kteich/freesurfer/dev --no-create --no-recursion ## --------- ## ## Platform. ## [dev/]$ ./configure --with-mni-dir=/usr/pubsw/packages/mni/current --prefix=/home/kteich/freesurfer/dev |
AC_OUTPUT( ... <list of files> ... MYPROG/Makefile ... <list of files> ... ) |
| Line 116: | Line 127: |
| Note: Do not just copy this example, use what's in your own {{{config.log}}} file! 6) Run {{{make}}} and verify that your binary program {{{MYPROG/MYPROG}}} was created. 7) Check in your changes. |
4) Modify {{{freesurfer/Makefile.am}}} to add {{{MYPROG}}} to the {{{MRISUBDIRS}}} or {{{MRISSUBDIRS}}} definition. (You can also alternatively add it to the end of any of the *SUBDIRS categories.) |
| Line 123: | Line 130: |
| [dev/] cvs ci -m "Added MYPROG" configure configure.in Makefile.am Makefile.in [dev/] cvs add MYPROG [dev/] cd MYPROG [MYPROG/] cvs add Makefile.am Makefile.in MYPROG.c myown.c [MYPROG/] cvs commit -m "First checkin." Makefile.am Makefile.in MYPROG.c myown.c |
## Makefile.am ## MRISUBDIRS= \ ... <list of files> ... MYPROG \ ... <list of files> ... |
| Line 130: | Line 139: |
| ==== autoconf Troubleshooting ==== | Once these 4 steps are complete MYPROG should automatically be built with the rest of !FreeSurfer. Try following the [[DevelopersGuide_git#Building|building steps from above]] to verify your binary compiles and builds successfully. |
| Line 132: | Line 141: |
| Here's a list of common problems and solutions for autotools problems: | === Working with git (Examples) === |
| Line 134: | Line 143: |
| [AutoconfTroubleshooting] ==== Making changes live ==== The current setup allows you to have your own private installation of FreeSurfer using {{{configure --prefix=/your/private/directory}}}. This lets you use {{{make install}}} to easily install the entire FreeSurfer environment into a local copy. The purpose of having your own private installation of FreeSurfer is to use it as a testbed to make sure that (1) your updates, whatever they be, work in freesurfer/ setup that is just like a real one, and (2) your updates are properly installed using 'make install' and 'make release'. Once you are sure of these two things, check in your updated files, including any Makefile.am and Makefile.in changes, etc, and the nightly build script will take care of the rest. The nightly build stuff automatically updates and installs the dev/ distribution on all seven build platforms. The next morning, just check if your changes are in any /usr/local/freesurfer/dev; if not, notify me. If they are in one /usr/local/freesurfer, they will be in the rest of them. (If any build/installs fail, I am notified, and will do the build/install manually for that day.) Things not to do: - Don't test your local setup by manually copying files into your local freesurfer/. Otherwise you can't be sure that the automated build will correctly install your files with 'make install' and 'make release'. The only way files should get into your freesurfer/ distro as with 'make install' and 'make release'. - Don't try to install into /usr/local/freesurfer yourself (i.e. by setting your .configure --prefix=... to target it). It's set up so the build scripts can do their job automatically. Also, you would only be installing on one of the seven platforms. It's a pain to do all three builds on all build machines and verify it all worked - that's what the nightly build script is for, so let it do it for you. If you absolutely need a 'hot fix' right away, and need to make changes live in any of the /usr/local/freesurfers before the nightly build stuff goes, let KevinTeich know and he'll do it. ==== How the nightly build works ==== First a note on the directory structure. In {{{/space/birn/50/freesurfer/build}}} there is a directory for each build machine. Each builds a platform in {{{/space/birn/50/freesurfer}}}, i.e. {{{/space/birn/50/freesurfer/rh7.3}}}. Currently these are as follows: || Build machine || Platform || || jupiter || suse91_x86_64 || || kani || rh9 || || minnehaha || fc2 || || fishie || centos4.0 || || storm || panther || || icelin || centos4.0_x86_64 || || caillou || rh7.3 || Inside each {{{/space/birn/50/freesurfer/build/MACHINE}}} is {{{trunk/}}} and {{{stable/}}}, as well as directories for local Qt installs and on Panther, MNI, and files for automated building. {{{configure_options.txt}}} contain command-line arguments for {{{configure}}} for that platform, and {{{source_before_building.csh}}} (optional) contains environment variables that must be set (mainly things like CPPFLAGS that are used by configure but can't be passed in to configure via the command line from a cronjob). The trunk and stable directories contain cvs checkouts. In {{{/space/birn/50/freesurfer/build/scripts}}} is {{{build_dev.csh}}} and {{{build_betapub.csh}}}. Each build machine runs {{{build_dev.csh}}} nightly. It basically goes to {{{/space/birn/50/freesurfer/build/MACHINE/trunk/dev}}} and does the following: |
==== Adding a new script ==== |
| Line 170: | Line 145: |
| cvs update -d make distclean rm -rf autom4te.cache aclocal autoconf automake ./configure `cat ${BUILD_DIR}/configure_options.txt` --prefix=/usr/local/freesurfer/dev make install |
git pull upstream git checkout –b nf-bay3-scripts <make changes> git add process_exvivo_diff_data_bay3.sh Makefile.am (all files related to commit) git commit –m “Added script to process exvivo diffusion data.” git push origin |
| Line 180: | Line 153: |
| The {{{build_betapub.csh}}} works in {{{/space/birn/50/freesurfer/build/MACHINE/stable/dev}}} and also does: | |
| Line 182: | Line 154: |
| {{{ make release prefix=/usr/local/freesurfer/pub }}} |
|
| Line 186: | Line 155: |
| All the autotools stuff gaurantees that enough of the Makefiles will be regenerated to ensure that new directories will be added to all Makefiles. This wouldn't normally be done with a simple {{{./config.status}}} because {{{configure}}} may need to be regenerated to know about new directories. Currently (as of 4/8/2005) the build_betapub.csh script is run regularly. This is to minimize interruption to the freesurfer/beta build. Note that all machines can run these scripts at any time from the command line. This lets a maintainer (KevinTeich) explicity do a build and install on any machine if a 'hot fix' is needed. Additionally, a developer can go to each machine's {{{/space/birn/50/freesurfer/build/MACHINE/trunk/dev}}}, update code, and do a {{{make install}}} from an individual binary directory if a hot fix is needed for a single binary before the nightly build. This is the quick and dirty way of doing an update for a single without waiting for the nightly build. For example, to update tkmedit, the developer would, for each build machine: {{{ cd /space/birn/50/freesurfer/build/MACHINE/trunk/dev/tkmedit cvs update make install }}} This would install the files to {{{/usr/local/freesurfer/dev}}}. However, the developer must know about file dependencies. In this case, the script files that tkmedit may also need to be updated, so the developer would also have to {{{cvs update}}} and {{{make install}}} from {{{dev/scripts}}}. === RPM === [RpmInfo] |
---- Send your comments/questions/feedback to zkaufman@nmr.mgh.harvard.edu |
Index
Contents
This page is targeted at Martinos Center users who wish develop within the Freesurfer code base and possibly contribute changes. Martinos and non-Martinos users who simply want to clone the repo and build on their home machine, but dont plan on contributing changes, should consult the read-only git repo. Lastly, users who just want access to the code can clone directly from the official freesurfer github page:
1. Getting the Source Code
In order to contribute changes to Freesurfer, a specific setup procedure needs to be followed where a users forks the Freesurfer github repository, clones the fork, and submit pull requests. This is described in detail here:
2. Building
Once the source code has been cloned the next step is building it. The steps required to building the Freesurfer code base are described below:
2.1. Setup Configure
It is necessary to run a pre-configure script, to create the platform specific tools required by configure (execute in the freesurfer directory created by git clone). This script runs a set of commands (aclocal, libtoolize, automake v1.9.6, autoconf v2.59) that creates the platform specific files for configure and puts them in the 'fsdev/config' directory.
./setup_configure
2.2. Configure
Now you need to configure your building parameters for your machine by running the configure script. Users at the Martinos Center should for the most part be fine with the default settings, but the configure script does accept many options for pointing to specific libraries and other build specific parameters. One exception is if a user wants to perform a local installation of FreeSurfer, he/she should use the --prefix flag. Type ./configure --help for a full list of options. For example:
## Default configuration ./configure ## Specify an installation location ./configure --prefix=~/freesurfer_install_dir ## See all possible options ./configure --help
Freesurfer builds against the following set of open-sourced libraries, which are installed under the /usr/pubsw/packages directory on all NMR computers:
Package
Version
Package
Version
CUDA
v5.0.35-rh5
ANN
v1.1
tiffjpegglut
v3.6, v6b, v3.7
itk
v3.16
VTK
v5.6
VXL
v1.14
MNI
v1.5
tcltktixblt
v8.4, v8.4, v8.1, v2.4z
KWWWidgets
CVS checkout
Qt
v4.7
wxWidgets
v2.8
cppunit
v1.10
xawplus
v3.1
petsc
v2.3
All these packages will be found by default by the ./configure script. But there are options to specify where certain packages exists if a user wishes to build against a different version of one of the open-source libraries. For example:
## Specify a specific version of qt ./configure --with-qt=/usr/pubsw/packages/qt/4.8.5/bin
2.3. Compile
You can now run 'make' to build the all individual programs in the FreeSurfer source tree. Binaries will automatically be placed in their individual subdirectories.
make -j 4
Handy hint: the -j 4 option to make tells it to run four simultaneous make processes, which, if building on a multi-processor machine, can speed-up the build.
If you want to compile just one binary at a time, for example, if you are developing an app, than cd to the directory of the program you want and use 'make' to compile it:
cd mri_info make
This creates mri_info in the mri_info/ directory. However, be aware the many program depends on the existence of libraries having already been build like libutils. Therefore users will need to build a few of the library directories first (e.g. utils, fsgdf, xml2, etc).
2.4. Install
To initial a local installation, type 'make install' from the top level directory:
make install
This will create a local Freesurfer installation in the directory as specified by the --prefix option to configure script (see above). Note that if you do not specify this location, it will try to install to /usr/local, which will probably require root access. The first time you run 'make install', it will take a while to copy all the big data files to the new installation. Subsequent 'make installs' will only copy the changed files.
If you only want to install a single binary, run 'make install' from a subdirectory. For example, running 'make install' from the mri_convert directory will copy the mri_convert binary to the proper locations. Running 'make install' from scripts/ will copy all the necessary scripts to the right location.
3. Adding a new binary to the tree
For this example we will assume you want to create a program called 'MYPROG' and want to add it to the FreeSurfer tree:
1) Make a directory called MYPROG under the freesurfer directory, and put your source code there. In the simplest case you will have a single source code file called MYPROG.c.
## Create the MYPROG directory and 'cd' into it mkdir MYPROG cd MYPROG ## The MYPROG.c file goes here
2) Copy freesurfer/dummy/Makefile.am into MYPROG/ and customize it, replacing 'dummy' with 'MYPROG'. Also delete the notes that are there. Be sure to change:
bin_PROGRAMS = MYPROG
3) Modify configure.in to add MYPROG/Makefile to the list of files in the definition of AC_OUTPUT (these are in roughly alphabetical order).
## configure.in ## AC_OUTPUT( ... <list of files> ... MYPROG/Makefile ... <list of files> ... )
4) Modify freesurfer/Makefile.am to add MYPROG to the MRISUBDIRS or MRISSUBDIRS definition. (You can also alternatively add it to the end of any of the *SUBDIRS categories.)
## Makefile.am ## MRISUBDIRS= \ ... <list of files> ... MYPROG \ ... <list of files> ...
Once these 4 steps are complete MYPROG should automatically be built with the rest of FreeSurfer. Try following the building steps from above to verify your binary compiles and builds successfully.
4. Working with git (Examples)
4.1. Adding a new script
git pull upstream git checkout –b nf-bay3-scripts <make changes> git add process_exvivo_diff_data_bay3.sh Makefile.am (all files related to commit) git commit –m “Added script to process exvivo diffusion data.” git push origin
Send your comments/questions/feedback to zkaufman@nmr.mgh.harvard.edu
