Wednesday, May 22, 2013

Combining Subjects with Different Scanning Parameters

As I was sorting through my fan mail yesterday, I came across a question from alert reader Joe Statin, asking whether it is OK to combine data from subjects with different scanning parameters; for example, if ten subjects were scanned with a TR of two seconds, and the other ten subjects scanned with a TR of four seconds, with everything else being equal. There are no definite answers for this, but in general, you need to ask yourself whether the difference in scanning parameters would make much difference. In the case of different TRs, a longer TR would result in slightly higher signal-to-noise ratio (SNR), but other than that, would not affect much else. (It would be much more difficult to carry out a meaningful finite impulse responses analysis looking at each acquisition individually, but in this case let's say we are dealing with simple contrasts across regressors.)

One way you can test this quantitatively is by directly comparing the beta estimates from one group of subjects, and comparing it to the other group of subjects that was scanned differently. If it doesn't appear to make much of a difference one way or the other, it is probably OK to combine both groups; if, however, there is a large difference, or if the results appear to be highly sensitive to whether someone was scanned with a two-second TR or a four-second TR, then you may want to hold off on combining them.

Combine the groups, and you will regret it; do not combine the groups, and you will regret it. Combine the groups or do not combine the groups, you will regret it either way. This, gentlemen, is the sum and substance of all philosophy.

Tuesday, May 21, 2013

3dROIstats: Promises and Pitfalls

Just as a follow-up to the previous post, with AFNI's 3dROIstats, it usually makes sense to assign different values to different ROIs; that way, when data is extracted from those ROIs, each one is labeled individually. Since every one of you you reads everything I write and watches everything I film, you probably noticed that I used a couple of different commands for combining ROIs, such as:

3dcalc -a roi1 -b roi2 -c roi3 -expr '(a+b+c)' -prefix outputfile

and, in the video,

3dcalc -a roi1 -b roi2 -c roi3 -expr 'step(a) + 2*step(b) + 4*step(c)' -prefix outputfile


The reason for assigning values increasing exponentially (1, 2, 4, 8, 16, etc) is to identify which voxels belong to a single ROI, and which voxels belong to overlaps of ROIs. For example, let's say that we have three ROIs, A, B, and C. Using weights of 1, 2, and 4 would result in the following table of values:

1: A only
2: B only
3: overlap of A & B
4: C only
5: overlap of A & C
6: overlap of B & C
7: overlap of A & B & C

By contrast, if you used weights of 1, 2, and 3, then the intersection of A and B would be indistinguishable from region C. (Of course, if do not think that any of your ROIs will overlap, then using discrete consecutive digits, such as 1, 2, 3, etc, is also fine.)

Once you have created your combined mask and are happy with the locations of your ROIs, the command 3dROIstats can be used to dump out data extracted from each ROI from one or more sub-briks (e.g., beta-maps) of a statistical dataset. The command is pretty straightforward, and this template command should be pretty much all you need:

3dROIstats -mask combinedMask+tlrc 'stats+tlrc[1,2,5,...etc]'

For each sub-brik specified in the dataset, 3dROIstats will dump out the average data value within each ROI. So, for example, if you have three ROIs in your mask and two sub-briks, 3dROIstats will output a 2x3 table with three values for each sub-brik, one for each ROI.

I hope that is as clear as a glaucous sky, which I think is a word that means unclear, or something. I just read it in a Cormac McCarthy novel and he uses a lot of words that I don't know. Whatever. I was trying to be ironic.

Monday, May 20, 2013

Combining ROIs

Once you've used a tool like fslmaths, 3dcalc, or Marsbar to create a single ROI, you can combine several of these ROIs using the same tools. This might be useful, for example, when creating a larger-scale masks encompassing several different areas.

In each case, combining ROIs is simply a matter of creating new images using a calculator-like tool; think of your TI-83 from the good old days, minus those frustrating yet addictive games such as FallDown. (Personal record: 1083.) With fslmaths, use the -add flag to concatenate several different ROIs together, e.g.:

fslmaths roi1 -add roi2 -add roi3 outputfile

With AFNI:

3dcalc -a roi1 -b roi2 -c roi3 -expr '(a+b+c)' -prefix outputfile

With Marsbar is a bit more involved, but also easier since you can do it from the GUI, as shown in the following video.




Many thanks to alert reader Anonymous, who is both too cool to register a username and once scored a 1362 on FallDown. Now all you gotta do is lay back and wait for the babe stampede!

Monday, May 13, 2013

Why Do Rednecks Do It Doggy Style?

So they can both watch NASCAR.

Now that I have your attention, I would like to turn to a more serious topic: Sub-brik selection in AFNI. If you have a small screen or simply too many sub-briks in your statistical dataset, it can be difficult, if not impossible, to select an appropriate sub-brik through the drop-down menu in the GUI. Instead, by right-clicking on the "OLay" or "Thr" text, you will get a scroll menu to select the sub-brik.



This, I hope, will save you countless hours of frustration and despair, and awaken your senses to the beauties of the world and touch your soul to the quick. At least, that's what I try telling myself every night when I hear the neighbors switch on NASCAR and start to get randy. Thin walls, guys!


As if a picture weren't enough, here's a video to go along with it. Since I can't help but overdo everything.

Friday, May 10, 2013

Parameter Extraction in AFNI: 3dmaskave and 3dmaskdump

Previously we showed how to extract parameters using Marsbar in SPM and featquery in FSL, and the concept is identical for AFNI. Once you have created a mask (e.g., using 3dUndump or 3dcalc), you can then extract parameter estimates from that ROI either using the tool 3dmaskave or 3dmaskdump.
3dmaskave is quicker and more efficient, and is probably what you will need most of the time. Simply supply a mask and the dataset you wish to extract from, and it will generate a single number of the average parameter estimate across all the voxels within that ROI. For example, let's say that I want to extract beta weights from an ROI centered on the left nucleus accumbens, and I have already created a 5mm sphere around that structure stored in a dataset called LeftNaccMask+tlrc. Furthermore, let's say that the beta weights I want to extract are in a beta map contained in the second sub-brik of my statistical output dataset. (Remember that in AFNI, sub-briks start at 0, so the "second" sub-brik would be sub-brik #1.) To do this, use a command like the following:

3dmaskave -mask LeftNaccMask+tlrc stats.202+tlrc'[1]'

This will generate a single number, which is the average beta value across all the voxels in your ROI.

The second approach is to use 3dmaskdump, which provides more information than 3dmaskave. This command will generate a text file that contains a single beta value at each voxel within the ROI. A couple of useful options are -noijk, to suppress the output of voxel coordinates in native space, and -xyz, to output voxel coordinates in the orientation of the master dataset (usually in RAI orientation). For example, to output a list of beta values into a text file called LeftNaccDumpMask.txt,

3dmaskdump -o LeftNaccDumpMask.txt -noijk -xyz -mask LeftNaccMask+tlrc stats.202+tlrc'[1]'

This will produce a text file that contains four columns: The first three columns are the x-, y-, and z-coordinates, and the fourth column is the beta value at that triplet of coordinates. You can take the average of this column by exporting the text file to a spreadsheet like Excel, or use a command like awk from the command line, e.g.

awk '{sum += $4} END {print "Average = ", sum/NR}' LeftNaccDumpMask.txt


Keep in mind that this is only for a single subject; when you perform a second-level analysis, usually what you will want to do is loop this over all of the subjects in your experiment, and perform a statistical test (e.g., t-test) on the resulting beta values.






Concluding Unscientific Postscript

I recently came across this recording of Schubert's Wanderer Fantasie, and I can't help but share it here; this guy's execution is damn near flawless, and, given both the time of the recording and some of the inevitable mistakes that come up, I have good reason to believe it was done in a single take. It's no secret that I do not listen to that much modern music, but it isn't that modern music is bad, necessarily; it's just that classical music is so good. Check out the melodic line around 16:30 to hear what I'm talking about.



Tuesday, May 7, 2013

Creating Spherical ROIs in AFNI Using 3dUndump

Regions of interest; everybody wants them, but nobody knows how to get them. However, as Megatron once said, power flows to the one who knows how; desire alone is not enough.

Aware of this, I have created a script which will disenthrall you from the pit of ignorance and give you the power to create ROIs just about anywhere you please. The script uses AFNI's 3dUndump, which creates a spherical ROI of a given radius from which parameter values can be extracted using a tool like 3dmaskdump. The rationale is similar to creating ROIs using fslmaths or SPM's marsbar; and if you understand those, using 3dUndump is essentially the same thing.

The only caveat is that you must know the orientation of your dataset before using 3dUndump. AFNI defaults to RAI orientation, in which numbers increase from right to left, anterior to posterior, and inferior to superior; in other words, coordinates to the right of the origin will be negative (since numbers decrease going from left to right), and coordinates anterior to the origin will be negative (since numbers again decrease going from posterior to anterior). Always make sure to check the orientation using a command like 3dinfo -orient before creating your ROI, or open up your anatomical dataset in the AFNI viewer and navigate to the location that you want (e.g., right nucleus accumbens) and then write down the coordinates displayed in the upper left corner of the viewer. You can also use the option -orient LPI, if you're using coordinates from a paper.

This Python script that will let you input the coordinates, and then output a dataset ROI that can be overlaid on your anatomical image. The script can be found here.


Tutorial on 3dUndump:



Tutorial on MakeSpheres.py



Thursday, May 2, 2013

Capital City Half Marathon

I and my sidekick (you haven't met her) always strive to bring you the hottest, moistest tutorial videos and neuroscience-related news, but I will be traveling to Columbus, Ohio to run the Capital City half marathon this weekend. Just thought you would like to know that I run more than you do, and am faster than you will ever be in your entire life. I also don't have a TV. Did you know that? Think about that the next time you're watching TV. I'm serious.

Wednesday, May 1, 2013

What Good is Neuroimaging?

If there is one absolute in this universe, it is that people want more stuff. Given the choice between stuff and nothing, people will choose stuff, nine times out of ten. Therefore, as science is a business as well as an intellectual pursuit, any scientist would be well-advised to take a step back once in a while and consider whether his work makes the public feel as though that they are getting more stuff. This gets back to the divide between basic research and translational research: basic research being done more for its own sake, and to just figure stuff out; and translational research, which attempts to bridge basic scientific findings and transform them into improved technologies or therapies.

A recent article in the Journal of Cognitive Neuroscience (Moran & Zaki, 2013) addresses these very issues, stating that neuroimaging has reached a critical mass of exploratory findings through brain mapping, but in order to advance will have to take a more theoretically rigorous approach. In the good old days, it was interesting to do basic exploratory analyses to examine the functional role of large chunks of cortical real estate, such as the visual cortex, auditory cortex, and some subcortical structures. However, the authors maintain that most new exploratory brain analyses - i.e., those that simply want to find out what brain region is responsive to a certain task or a certain stimulus - are rapidly entering the far end of diminishing returns. What is needed, rather, is experiments that can adjudicate between competing theories of brain function, using forward inference to distinguish between alternative hypotheses, instead of reverse inference, which reasons that because a particular region shows more activity than normal, then a particular process must be involved (cf. Poldrack, 2006).

However, even with reverse inference, some assumptions can be made about a cognitive state. For example, with large-scale databases such as Neurosynth, one can quickly see how many studies claim that a given region is involved in a particular cognitive process. This lends more credibility to reverse inference claims that dovetail with evidence from the majority of studies, as opposed to selecting a single study that claimed to have found evidence of a cognitive process associated with a certain area, as this may be more susceptible to a false positive.

For practical uses, however, neuroimaging - and FMRI in particular - has been able to make predictions about behavior based on brain activity. For example, in a growing body of decision-making research, increased activity in the anterior insula predicted better choices in a risky decision-making task (Krawitz et al, 2010), and within a group of smokers shown anti-tobacco ads, dorso-medial prefrontal cortex activity predicted levels of a nicotine metabolite at a later follow-up (Wang et al, 2013). This seems to be a profitable avenue of neuroimaging research, as neural activity can provide more information about effective treatment programs, from drug PSAs to psychological therapies, above and beyond behavioral measures.

In light of all this, the evidence suggests that, although brain mapping for its own sake will continue to be popular, the higher-impact work appears to be shifting more emphatically in the direction of translational research. The human desire for stuff will always trump the human desire of curiosity, and the researcher would be wise to pay heed to this, lest he be swallowed up in darkness.