Friday, September 5, 2014

FSL Tips

Automatic Atlas Query

If you need a table with the coordinates and atlas labels of clusters in a nifti map, check out this script written by Brainder. In his words, any information that is not shared is lost, so I hope he doesn't mind me sharing his script here.


Colorbars

To make colorbars for your figures when using fslview, navigate to: /usr/local/fsl/etc/luts (or wherever you save your FSL directory), and find colorbar.nii.gz. Open that file in fslview and you can change the colors to the ones matching your figure. Then screenshot the image.

fslorient2std
Very often, the files you obtained from the scanner are oriented in a weird way, and are incompatible with the MNI152 Standard Template Image used in registration. Use this command to reorient the image so that they appear the "same way round" in FSLVIEW (note, your original images do have to have the correct header information)

Thursday, September 4, 2014

Face Stimuli

Thinking of running a psychology/neuroscience study with faces as stimuli? Here are some face databases:

NimStim Set: http://www.macbrain.org/resources.htm
* Hmm, I find the photos a little weirdly cropped. The hair looks really strange.
* If you find the faces strange, it usually helps to morph several faces together (e.g., using Fantamorph).

Karolinska Directed Emotional Faces (KDEF): http://www.emotionlab.se/resources/kdef

Chicago Face Database:
http://faculty.chicagobooth.edu/bernd.wittenbrink/cfd/index.html
  • 158 photographs of Black and White individuals. Targets are represented with the following expressions:
    • neutral
    • angry
    • happy (with open mouth)
    • happy (with closed mouth)
    • fearful

Thursday, August 28, 2014

Settling into Grad Student Life at Stanford (August 2014)

I've received quite a few helpful tips as I settled into life at Stanford... I thought I would take a few minutes to write some of them down, in case they may be of use to "future generations". Note that this information is accurate as of August 2014!

Checking-in Early - I arrived a couple of days earlier than the designated check-in date. I wrote in to housing, and they were kind enough to let me check-in a day earlier... In general, I've found the housing staff to be quite helpful and friendly. So if there's anything you need from them, I would say to not hesitate to ask (nicely).

Arrival at the Airport - Take the supershuttle. The cheapest option (shared mini-van) is fine. Stanford discount available here. You shouldn't have to wait more than 20 minutes. The shuttle is parked on the 3rd floor at a curb across the road. If in doubt, just ask the information center, they'd know.

Dorm Essentials - Online shopping ftw.
Google Shopping Express provides one-day delivery for pretty much everything you need. Currently, they only service Bay Area (including Stanford), SF, LA, and Manhattan. The way this works is that when they receive you order, they'll hop onto an environmentally friendly Toyota Prius, go to the respective stores (e.g., Target, Walmart), pick up the stuff, and drop it at your place, *on the same day*. In other words, you can check into your housing residence in the morning, find out your mailing address (housing won't release your mailing address before you check in), and have pillows and sheets shipped to you by 9pm. How cool is that! If you sign up now, you get 6-month trial membership that includes free delivery. Note that this service is currently in beta-testing stage... I really hope it won't go the way of Google Reader (i.e. discontinued)

There's of course also Amazon Student, which lets you get Amazon Prime free for 6-months. The service is pretty similar to Google Shopping Express, except it's next day delivery. In general though, I think you are more likely to find esoteric items on amazon then google express.

Soap.com (and sister sites): 3 months of free next-day shipping on all household items you could possibly need. Likely to be cheaper than Google Express

Craigslist - Doesn't require an introduction

SUpost - Craigslist in the Stanford area. Useful for dorm-essentials, bikes and cars.

Food!
Online shopping ftw again. Amazon Fresh Food provides same day delivery of meat and produce. DashFood delivers from restaurants, including one Singaporean Restaurant!

Transportation 
Car Rentals: ZipCar

BikeShop: I bought my bike at the Campus Bike Shop at Tresidder Union. It was a little pricey, but it was the most convenient option.... Plus, the SUID Card office is on the second floor of Tresidder Union, so I managed to do both things at once on the first day of arrival.

International Students Loan Closet
If you are an international student, be sure to check out the international students loan closet. They loan out a lot of household items, for as long as you are on campus, for a nominal registration fee of $10. Look at what I got!


The loan closet is in the basement of Abrams, EV. But you'll have to make an appointment first at the I-Center.

How to get to the DMV by public transport
If you do not have a US license, you'll need to schedule an appointment with the DMV to take a written test, as well as a behind-the-wheel driving test. The international center has pretty good information on this, so I won't repeat it here.

If you have a US license, but from another state, you will not have to take the behind-the-wheel driving test, but you do need to take the written test. Making an appointment will save you quite a bit of time, but appointments fill up ~3weeks in advance, so you'll have to plan ahead. I didn't make an appointment, went to the DMV when it opened and there was already a line outside o.O. Though I was in-and-out of there in 2 hours, so it isn't too bad really. Make sure you have all your documents (I-20, I-94, passport and out-of-state license) when you are there!

There are two DMVs near Stanford - Redwood City & Santa Clara. Both are really easy to drive to... but Redwood City is more convenient via public transport. For Redwood City, take the Caltrain (from Palo Alto or California Avenue), alight at the Redwood City Station and walk 12 minutes to the DMV.


For Santa Clara, you can take bus 22 from El Camino.

Musings
1. Most things can be accomplished online. There seems to be no need to head out to shopping centers anymore. I'm not sure if that's a good thing.

2. Paradox of choice - with so many options, I feel compelled to look up all of them and find the best buy, which is incredibly difficult with different packaging, sizes, quality etc. I also feel obliged to read the reviews, and people can have such different opinions. Ugh, I hope this doesn't mean I spend all the time saved from going shopping in front of the computer.

Acknowledgments
A lot of the above information came from Erika Weisz, who has been immensely helpful as I settle into Stanford :)

Sunday, August 24, 2014

Emailing Professors for Research Opportunities: Dos and Dont's

I received an email from a high school senior today, enquiring if I was looking for a research assistant. It was very well worded and polite, but clearly a form letter. Since it's the summer, and I have a bit of time on my hands, I thought I would reply to him with a few tips on how to better write these emails (I have accumulated quite a bit of experience over the years :p).

I won't post his original email, but here's what I said:

1. Don't send emails using bcc. Professors receive many such emails a day and have to choose which to respond to. The less yours feels like a mass email, the more likely you'll receive a response. 

2. Address the recipient appropriately (most grad students would be ok with a first name, but mr [last name] might be safer; Dr. [last name] for post-docs and Professor [last name] for faculty.

3. State clearly in the first paragraph your current education level. Vacancies are different for high school freshmen, seniors, undergrads and college grads. The recipient shouldn't have to figure it out themselves from your resume.

4. You need to be a little more specific about your research interests. It's good to have broad interests, especially when you are in high school, but you need to elaborate. Listing fields (i.e. "psychology, sociology, neuroscience, and medicine") actually tells the recipient very little about what you are interested in, and as such, difficult for him/her to figure out whether you would be a good fit for the lab. 

5. 
Specifically, I am interested in the subject of your research and would love to further investigate my passion for it. 

This sounds a little insincere if you had not demonstrated some knowledge that you know what the recipient's research is about. Show that you've done some homework and did not send the same email to a 100 .edu addresses. So comment intelligently on the recipient's research focus, and how his/her work fits with your own research interest.

I hope he doesn't take it the wrong way! Just thought these tips would give him a better chance in his search!

Thursday, July 10, 2014

Within-Subject Error Bars

Psychologists and neuroscientists often plot error bars to show the variability in their obtained results. Very often, the error bar shows the standard error of the mean, or SEM. A quick rule of thumb when looking at graphs is to check whether the error bars between conditions overlap - if they do, you can conclude that the the means are NOT significantly different at p < 0.05. Note that the converse is not true, that is, non-overlapping error bars ≠ significant difference. The means have to be approximately 3SEM apart (assuming the two means have similar SEMs).

This rule, however, only applies to between-subject designs. What about within-subject (i.e. repeated measures) designs? Error bars would be too large as they take into account both between-subject and within-subject variance (variability in the paired difference between the different conditions in the same subject). In my opinion, plotting between-subject SEM for within-subject tests (e.g. paired t-tests) is meaningless, because conflating between-subject and within-subject variance makes the error bars uninterpretable.

A solution was first proposed by Loftus and Masson (1994). Briefly, it involves running a repeated measures anova, and taking the mean squared error (MSE) from the appropriate (repeated-measures) ANOVA analysis (i.e. the denominator from the appropriate F-test). SEMwithin can then be calculated by taking the square root of MS divided by N. This procedure works because a repeated-measures ANOVA removes between-subject variance first, so the MSE captures only within-subject variability.

If all you want to know is how to plot within-subject error bars, you can stop reading here. If you would like a more nuanced discussion, read on.

**************************

The Loftus and Masson method, however, yields a single SEM value for all conditions. The implicit assumption is that the variance between the pairwise difference between conditions is constant (i.e. sphericity assumption). Of course, this assumption can be tested and corrected (e.g., Greenhouse-Geisser or Huynd-Feldt). But wouldn't it be nice if we could just tell from the error bars (i.e. the same way we can tell if the homogeneity of variance is violated from the error bars of a between-subject design)? This prompted Cousineau (2005) to propose a different solution, which involves "normalizing" data from all subjects such that the between-subject variance is removed. This is done by subtracting, for each condition and subject (i.e. each "cell"), the subject average across conditions, and then adding the grand average of all cells. Hence all subjects will have the same average, but the within-subject effects are preserved. The SEM can then be calculated as per normal, and each condition will have it's own error bar. Cousineau, unfortunately, did not take into account the fact that normalization (in particular, adding the grand average of all cells) induces positive correlations between the cells, so the error bars are a little too small compared to those calculated by the Loftus and Masson method. This discrepancy was identified by Morey (2005) who proposed a simple solution of multiplying the Cousineau variance (note: NOT SEM) by M/(M-1), where M = number of conditions, before calculating error bars**.

Ahh... but the story is not over yet. I just found out that Franz and Loftus (2012) published a recent study challenging the normalization method. They argue that the normalization method does not actually allow for the checking of the sphericity assumption and even though the method produces different error bars for each condition, any difference in the error bars will not not interpretable. Specifically, sphericity requires inspecting all pairwise differences between conditions, and the only way to do it visually, is to plot all the pairwise differences, and see if the variance of those pairwise differences are similar. Franz and Loftus argue that these pairwise differences should be plotted next to the plot of means for visual inspection.

My thoughts? I have to say, I still recommend Loftus and Masson + appropriate test for sphericity. It isn't THAT difficult to compute - an actual charge by detractors of the method. I mean, it's not computationally intractable or anything - just run the ANOVA >.<. That said, I wouldn't write off a paper which uses Morey (2005). For the purpose of "eye-balling" significance... those error bars do the trick as well. And the condition-specific variance reflected in those error bars is still information (though I need to think a little harder about what it might be good for). At the end of the day, I see error bars as visual aids*. Authors ought to be clear and honest about how the error bars were obtained. Readers, however, should always defer to the results of the appropriate statistical test to evaluate findings.

*On that note, I don't really think plotting the variability of the pairwise differences is all that useful. If there are say, 6 conditions... you'll need to plot 15 pairwise differences... and that's not really all that helpful for visualization, which defeats the purpose of graphing in the first place.

** Previous version of this posts states that the correction is M/(M-1). Thanks to Eric Garr for pointing out the mistake :)

Thursday, May 29, 2014

Setting up my new laptop

I recently bought a new laptop, nothing fancy - just another MB Pro. My general resistance to change (and yes, I know it's a character flaw) compelled me to buy something that would require minimal time to get used to. At the same time, I do like to start afresh, so I rarely transfer settings/preferences from my old computer to the new one, which means that for the preferences that I do like to keep, I'll have to reconfigure them again.

Unfortunately, I have forgotten how I made those changes in the first place (especially the small ones), and had to figure them out one-by-one. So I thought I would start a post with the steps I took to set up this laptop, and I'll have something to refer to for the next

Let's start with Google Chrome

1. I was rather annoyed when they took google scholar away from the google page (this was about what, 3 years ago now?), because it meant a few extra clicks needed to search for a paper. I know it's not THAT much time, but hey, minimize all transaction cost right ;). Fortunately, Chrome allows you to search from different search engines from the "omnibar" (seriously, the address bar is a much more intuitive name). This is how you do it:

Chrome > Settings > Search > Manage Search Engines
Add:
First Column - Google Scholar (or name of any other search engine)
Second Column - Easy to type shorcut (I use "s")
Third Column - http://scholar.google.com/scholar?hl=en&q=%s

The next time you want to do a google scholar search, all you need to do is to type the shortcut in the address bar, and there you go, google scholar in your address bar!

2. Default font in blogger
Blogging in Times feels so formal, which discourages me from blogging. I've changed the default font on blogger to Arial, just so I don't have to change it everytime. This is a chrome setting, and not a blogger setting. To change it, go to

Chrome > Settings > show advanced settings > Web Content > Customize Font > Standard font

Changing the standard font here will change the default font in blogger.

3. Syncing Zotero with Dropbox
Zotero is a citation management application. It's the one I use, no special reason, since I think the major ones are all pretty similar. That said, I do have a soft spot for zotero because it's open source and not owned by a certain publishing giant.

I am hoping to make any computer a working computer, so I'm slowly migrating everything to cloud servers. It would be nice if I had all my papers in one place accessible from anywhere/even offline. To do this with zotero, simply create a zotero folder in dropbox, and change the appropriate settings in zotero for all computers.

Zotero > Preferences > Advances > Data Directory > Custom > (path to dropbox zotero folder)

Wednesday, May 14, 2014

Model-based fMRI

Standard fMRI analysis uses GLMs, so most fMRI analyses are technically "model-based". But that's not what I am going to write about today. Instead, I will be talking about model-based fMRI where one combines computational models of cognition with fMRI to find neural correlates of different cognitive processes. I only hope to give an introduction to the topic. For a more detailed treatment, one can turn to the following two resources:

Daw, Nathaniel D. "Trial-by-trial data analysis using computational models."Decision making, affect, and learning: Attention and performance XXIII 23 (2011): 3-38

and 

O'Doherty, John P., Alan Hampton, and Hackjin Kim. "Model‐Based fMRI and Its Application to Reward Learning and Decision Making." Annals of the New York Academy of Sciences 1104.1 (2007): 35-53.

What is model-based fMRI?
For many years, psychologists have built computational models to study human cognition. These models describe cognitive processes in terms of algorithms (variables and operations). They are then fit to behavioral data collected from real human participants to assess if the cognitive processes posited by the model are indeed descriptive of participants' mental operations. 

Model-based fMRI is an extension of the computational modeling of cognition. Instead of fitting to behavioral data, the computational models are fitted to fMRI data time-series. Finding neural activity that encodes the cognitive variables assumed by the model would provide additional validity of the models, and provide insight into how the cognitive operations assumed in the model might be implemented in the brain.

Why do model-based fMRI?
As I see it, there are two main advantages:
1. Computational models will allow you to track the trial-by-trial dynamics of cognitive/neural processes, so you can see them unfold over time. Both event-related trial-averaging and block designs lose this level of granularity.

2. Model-based fMRI allows you to study how a cognitive process is implemented in the brain, and not just where it is occurring. While localization of function is important, I do think that most neuroscientists would agree that we would prefer if we could understand brain function at the mechanistic level.

A recipe for  standard model-based fMRI
This is taken from O'Doherty et al. (2007), which I recommend to anyone who is interested in using model-based fMRI for their studies.
  1. Fit computational model to participants' behavioral data to obtain optimal model parameters that maximize the "fit" between model and data.
  2. Using the best-fitting model and model parameters, generate a time-series for the cognitive variable of interest (e.g. value of chosen stimulus, prediction errors, confidence etc etc.). This time series can be thought of as the experimenter's best estimate of what the participant is "thinking" at each time point.
  3. Convolve time-series with the hemodynamic response function. The resulting time-series can be thought of what the BOLD activity of a brain area encoding the cognitive variable of interest would look like, given the experimenter's best estimate of the variable.
  4. Regress time-series with fMRI data to find voxels that correlate with cognitive variables of interest
I'd be happy to talk about the method. Leave a comment or drop me an email.