|
Size: 8645
Comment:
|
Size: 8216
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 6: | Line 6: |
| <<TableOfContents(3)>> | <<TableOfContents>> |
| Line 8: | Line 8: |
| This page is targeted at those who have access to the FreeSurfer source code, and wish to build this source code on their own Unix platform (whether it be an NMR Martinos Center platform, which has all required libraries, or on some arbitrary Unix platform, where the dependent libraries must be installed prior to building FreeSurfer). | This page is targeted at Martinos Center users who wish to inspect, build or develop within the Freesurfer code base. Non-Martinos users wishing to work with the Freesurfer code base should consult the [[http://surfer.nmr.mgh.harvard.edu/fswiki/freesurfer_linux_developers_page|read-only git repo]]. Users who with to contribute to the Freesurfer code base and/or commit changes to the repo should [[https://surfer.nmr.mgh.harvard.edu/fswiki/Freesurfer_github|see the following page]] describes how to fork the Freesurfer github repository and submit pull requests . |
| Line 10: | Line 10: |
| === Git Clone === | === Getting the Source Code === |
| Line 12: | Line 12: |
| First thing users at the Martinos Center will need to do is add the following directory to their PATH environment variable. This is to use a newer version of the {{{git}}} and {{{git-annex}}} software than the one installed native on the computers at Martinos Center. | The first thing users at the Martinos Center need to do is '''prepend''' the directory {{{/usr/pubsw/packages/git-annex/current/bin}}} to their PATH. Once that is done, the Freesurfer source code can be cloned from the official [[https://github.com/freesurfer/freesurfer|Freesurfer github page]]: |
| Line 15: | Line 15: |
| ## csh $> setenv PATH /usr/pubsw/packages/git-annex/current/bin:$PATH ## bash $> export PATH=/usr/pubsw/packages/git-annex/current/bin:$PATH |
git clone git@github.com:freesurfer/freesurfer.git |
| Line 22: | Line 18: |
| Users can then clone !FreeSurfer repository as follows: | ==== Get the Data Files ==== The Freesurfer repository contains a large number data files which are not included with a default {{{git clone}}} of the repo. Instead, these data files are distributed via the [[https://git-annex.branchable.com/|git-annex]] software. Users who only want the repository for the purposes of compiling binaries and/or inspecting source code, the {{{git clone}}} command from above is all you need to do. Users who want to run build time checks, or perform a full local installation, or just want all the contents of the repository, will need to add a special data store remote repository in order to retrieve these files. To add the data store repository (this only needs to be done once): {{{ git remote add datasrc file:///space/freesurfer/repo/annex.git git fetch datasrc }}} And to retrieve data files: |
| Line 25: | Line 30: |
| ## Get source code files (206 MB) $> git clone file:///space/freesurfer/repo/freesurfer |
git annex get <filename> |
| Line 29: | Line 33: |
| ==== Remote git Access ==== Outside of the Martinos Center, users can download !FreeSurfer source code via the read-only git repo: {{{ $> git clone https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/repo/freesurfer.git }}} More information about building !FreeSurfer outside the Martinos Center can be found here: http://surfer.nmr.mgh.harvard.edu/fswiki/freesurfer_linux_developers_page ==== Getting the Data Files ==== The !FreeSurfer repository contains a large number data files (pdfs, test data, etc) which are not included with a default {{{git clone}}} of the repo. Users who only want the repository for the purposes of inspecting source code and/or compiling binaries, the {{{git clone}}} command from above is all you need to do. Users who want to run build time checks, or perform a full local installation, or just want all the data files contained in the repository, will need to run the following command: |
The data files have been broken down into categories, those being required for build time checks, those required for a local installation, and everything else. Use one of the following commands depending on your needs: |
| Line 46: | Line 37: |
| $> git annex get --metadata fstags=makecheck . | git annex get --metadata fstags=makecheck . |
| Line 49: | Line 40: |
| $> git annex get --metadata fstags=makeinstall . | git annex get --metadata fstags=makeinstall . |
| Line 52: | Line 43: |
| $> git annex get . | git annex get . |
| Line 54: | Line 45: |
| Line 59: | Line 51: |
| 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 'dev/config' directory. | 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 62: | Line 54: |
| $> ./setup_configure | ./setup_configure |
| Line 71: | Line 63: |
| $> ./configure | ./configure |
| Line 74: | Line 66: |
| $> ./configure --prefix=~/work/freesurfer | ./configure --prefix=~/freesurfer_install_dir |
| Line 77: | Line 69: |
| $> ./configure --help | ./configure --help |
| Line 81: | Line 73: |
| !FreeSurfer builds against the following set of open-sourced libraries, which are installed under the {{{/usr/pubsw/packages}}} directory on all NMR computers: | Freesurfer builds against the following set of open-sourced libraries, which are installed under the {{{/usr/pubsw/packages}}} directory on all NMR computers: |
| Line 83: | Line 75: |
| * CUDA (v5.0.35-rh5) * tiffjpegglut (v3.6, v6b, v3.7) * VTK (v5.6) * MNI (v1.5) * KWWWidgets (CVS checkout) * wxWidgets (v2.8) * xawplus (v3.1) * ANN (v1.1) * itk (v3.16) * VXL (v1.14) * tcltktixblt (v8.4, v8.4, v8.1, v2.4z) * Qt (v4.7) * cppunit (v1.10) * petsc (v2.3) |
|| 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 || |
| Line 102: | Line 88: |
| $> ./configure --with-qt=/usr/pubsw/packages/qt/4.8.5 | ./configure --with-qt=/usr/pubsw/packages/qt/4.8.5 |
| Line 104: | Line 90: |
For users outside the Martinos Center, a package of all these compiled open-source libraries are available on the distribution site. See the "Library Dependencies" section of the the developers guide for instructions on how to obtain this bundle and build against it: https://surfer.nmr.mgh.harvard.edu/fswiki/freesurfer_linux_developers_page#LibraryDependencies |
|
| Line 111: | Line 93: |
| You can now run 'make' to build the !FreeSurfer source tree: | 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. |
| Line 114: | Line 96: |
| $> make -j 4 | make -j 4 |
| Line 118: | Line 100: |
| You could compile individual programs or all of them at once. To compile all of them, just run 'make' from dev/. Binaries will automatically be placed in their individual subdirectories. If you want to compile just one binary at a time, if you are developing an app for example, than {{{cd}}} to the directory of the program you want and use 'make' to compile it: | 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: |
| Line 120: | Line 102: |
| $> cd mri_info $> make |
cd mri_info make |
| Line 127: | Line 109: |
| To install all binaries and support files into your private !FreeSurfer installation, type 'make install' from the toplevel dev/ directory, like this: | To initial a local installation, type 'make install' from the top level directory: |
| Line 130: | Line 112: |
| $> cd dev $> make install |
make install |
| Line 134: | Line 115: |
| This will create a local !FreeSurfer installation in the directory specified by the {{{--prefix}}} option to {{{configure}}} scipt (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. | 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. |
| Line 136: | Line 117: |
| Note that you can also run 'make release'. 'make install' makes and installs the NMR internal version of FreeSurfer, while 'make release' makes the public version which omits some stuff. 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 scuba/ directory will copy the scuba binary and its support script files to the proper locations. Running 'make install' from scripts/ will copy all the necessary scripts to the right location. |
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. |
| Line 144: | Line 121: |
| Assuming that you have a source file {{{MYPROG.c}}} that compiles into MYPROG and want to add it to the !FreeSurfer tree: | For this example we will assume you want to create a program called 'MYPROG' and want to add it to the !FreeSurfer tree: |
| Line 146: | Line 123: |
| 1) Make the directory in dev and copy the source file there. Name the directory MYPROG and the source file {{{MYPROG.c}}}. | 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}}}. |
| Line 149: | Line 126: |
| mkdir dev/MYPROG cp MYPROG.c dev/MYPROG |
## Create the MYPROG directory and 'cd' into it mkdir MYPROG cd MYPROG ## The MYPROG.c file goes here |
| Line 153: | Line 132: |
| 2) Modify {{{dev/configure.in}}} to add {{{MYPROG/Makefile}}} to the list of files in the definition of {{{AC_OUTPUT}}} (these are in roughly alphabetical order). | 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). |
| Line 167: | Line 153: |
| 3) Modify {{{dev/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.) | 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 179: | Line 165: |
| 4) Copy {{{dev/dummy/Makefile.am}}} into {{{MYPROG/}}} and customize it, replacing 'dummy' with 'MYPROG'. Be sure to change: | 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 181: | Line 167: |
| {{{ bin_PROGRAMS = MYPROG }}} |
=== Contributing Changes === Users who with to contribute to the Freesurfer code base and/or commit changes to the repo should see the following page which describe how to fork the freesurfer repository and submit pull requests: |
| Line 185: | Line 170: |
| and also delete the notes that are there. === Using Git === If your program successfully builds/installs/runs and is thus ready to be checked into the repository, you can commit the files as follows: {{{ $> cd dev/MYPROG $> git add MYPROG.c Makefile.am $> git commit -m "Initial add of MRPROG." MYPROG.c Makefile.am $> git push }}} Data files represent a special use-case as they should not included in the default Additional information on how to use Git can be found on the Atlassian websites which has decent tutorials and examples to help users getting started with Git: [[https://git-scm.com/docs/gittutorial|https://git-scm.com/docs/gittutorial]] |
https://surfer.nmr.mgh.harvard.edu/fswiki/Freesurfer_github |
Index
Contents
This page is targeted at Martinos Center users who wish to inspect, build or develop within the Freesurfer code base. Non-Martinos users wishing to work with the Freesurfer code base should consult the read-only git repo. Users who with to contribute to the Freesurfer code base and/or commit changes to the repo should see the following page describes how to fork the Freesurfer github repository and submit pull requests .
1. Getting the Source Code
The first thing users at the Martinos Center need to do is prepend the directory /usr/pubsw/packages/git-annex/current/bin to their PATH. Once that is done, the Freesurfer source code can be cloned from the official Freesurfer github page:
git clone git@github.com:freesurfer/freesurfer.git
1.1. Get the Data Files
The Freesurfer repository contains a large number data files which are not included with a default git clone of the repo. Instead, these data files are distributed via the git-annex software. Users who only want the repository for the purposes of compiling binaries and/or inspecting source code, the git clone command from above is all you need to do. Users who want to run build time checks, or perform a full local installation, or just want all the contents of the repository, will need to add a special data store remote repository in order to retrieve these files.
To add the data store repository (this only needs to be done once):
git remote add datasrc file:///space/freesurfer/repo/annex.git git fetch datasrc
And to retrieve data files:
git annex get <filename>
The data files have been broken down into categories, those being required for build time checks, those required for a local installation, and everything else. Use one of the following commands depending on your needs:
## Get only the data files required for build time checks (1.9 GB) git annex get --metadata fstags=makecheck . ## Get only the data files required for local installation (4.3 GB) git annex get --metadata fstags=makeinstall . ## Just give me everything! Not Recommended (6.8 GB) git annex get .
2. Building
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
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. Contributing Changes
Users who with to contribute to the Freesurfer code base and/or commit changes to the repo should see the following page which describe how to fork the freesurfer repository and submit pull requests:
