Hi Patrick,
This is something I've been dabbling in (still very much a work in progress) and below are some general approaches and things to keep in mind that I've found helpful for wrapping my brain around the complexity of SPM.
-- First, unless you are intimately familiar with MATLAB UI control and can follow callbacks easily, trying to get at what the batch interface is doing specifically, may not be the best start for tracking down the meat of SPM computations. Rather in the batch, you have the option of saving a script for your batch and this seems to be a good place to get a foothold without diving into the messiness of graphical interfaces. It can help illustrate how the matlabbatch that specifies the parameters of your particular analysis is structured and how that is used by spm.
-- Breakpoints are your friend. One of the few beautiful things about MATLAB is the seamless interactive debugging. Not only can you set and remove break points while code is running in debug mode, you can step into and out of functions. Either try setting a break point at spm_jobman in the script saved from your batch, or to see how SPM is initialized, try setting a breakpoint in the file spm.m
-- On the point of degugging, loading and visually inspecting values of variables in the variable editor as they move through code is also useful. It can also be educational to modify these values and see how they change final results or cause errors. When errors happen, the stack trace is great for orienting to the location of the failure.
-- Don't fall into assumptions of how code should be structured. Keep in mind that SPM was written by several contributors and there does not seem to be consistent code standards. This can be as obvious as the use recursive switch/case statement in some files and function encapsulation in others, but it can also be more subtle like spm_get passing something labelled height threshold to spm_uc while it being labelled alpha value inside the function. Perhaps this is more reflective of my lack of understanding, but I found the latter type of inconsistency to be particularly tricky.
If you find any insights into how SPM operates I hope you will share them with the community. I've been aching for a more comprehensive description of SPM's code implementation!
Luck,
Meg
|