External Email - Use Caution
Dear community: I was curious about how the software is made and I decided to write an email to Dr. Bruce Fischl who answered all of the questions I asked, but he gave me the input to ask these questions also in FreeSurfer Community. I first asked the programming language of the software(I didn’t know that it was even open source). He says its mostly C but also some Matlab and C++. I am concerned with the long preprocessing time of raw T1 data so if anyone has some insights about which is the longest part and how faster it can get with nowadays hardware of course share with us. I think perhaps if some of the code of C were translated to C++ may be it could be faster. Although I don’t know how faster in fact but it could be a start. It should be easier if there were someone with clear head picture of time processing in different parts of the program in different hardware specifics. I know there is an entry in FreeSurfer wiki but I’m talking of an exchange of experiences with different machines with the same version of the software. May be I am going too far on my expectations. It would be nice to have a thread where we all shared our knowledge about how to improve performance. May be programming language translation is a bit of a lazy start and a change in some of the algorithms is the what we should encourage.
Sincerely, Andrade.
External Email - Use Caution
Dear Andrade,
I've only had a brief look at some parts of the FreeSurfer source code, but as I've worked as a software engineer for a while, maybe some more general comments on your thoughts:
On the idea of translating the source to C++: I highly doubt that this will lead to improved performance. I would expect no improvement or even slightly worse performance. You are not getting better algorithms by translating source code. What's more relevant is the compiler that will translate the source code to the executable format. As the various compilers available for both C and C++ are quite mature and optimized, I would not expect any relevant performance difference. (I can also tell you that in the industry, I never heard anybody suggest that approach.)
On hardware to make it faster: the majority of the work in FreeSurfer is done by the CPU, so getting a fast CPU will definitely give you speedups. Given the amount of data that has to be read and written, an SSD may also help a bit.
What's way more important though is that modern CPUs have many cores, and in general only one of them is used by a single FreeSurfer instance, so you should definitely run several processes (for different subjects) at the same time. You could use tools like GNU Parallel, simple shell scripts with background jobs, GNU Screen or similar to make this a bit easier. You could even use a computer cluster with a job scheduler to run *way* more subjects in parallel.
On measuring the run time for parts of the FreeSurfer pipeline: I am not sure how much is logged in the output already, but I guess it should be possible to make recon-all log timestamps for the parts listed here https://surfer.nmr.mgh.harvard.edu/fswiki/ReconAllTableStableV6.0 without much effort.
I hope this answer helps and isn't too disappointing.
Best,
freesurfer@nmr.mgh.harvard.edu