Below (indented) is a straightforward MATLAB/SPM/Marsbar script for generating separate Marsbar ROI and Nifti ROI spheres (user-defined radius) from a set of user-defined MNI coordinates stored in a text file (‘spherelist.txt’ saved in the same directory as the script).  ROI files are saved to mat and img directories that the script creates.
I use this script to generate *.mat files as seeds for resting connectivity analyses.  Once a *.mat ROI is generated, Marsbar can be used to extract raw timecourses from this region to feed into connectivity analysis as the regressor of interest.  Because MRIcron doesn’t read *.mat Marsbar ROI files, I render the equivalent *.img seed regions on a canonical brain when I need to present them graphically.

% This script loads MNI coordinates specified in a user-created file,
% spherelist.txt, and generates .mat and .img ROI files for use with
% Marsbar, MRIcron etc.  spherelist.txt should list the centres of
% desired spheres, one-per-row, with coordinates in the format:
% X1 Y1 Z1
% X2 Y2 Z2 etc
% .mat sphere ROIs will be saved in the script-created mat directory.
% .img sphere ROIs will be saved in the script-created img directory.
% SPM Toolbox Marsbar should be installed and started before running script.

% specify radius of spheres to build in mm
radiusmm = 4;

load(‘spherelist.txt’)
% Specify Output Folders for two sets of images (.img format and .mat format)
roi_dir_img = ‘img’;
roi_dir_mat = ‘mat’;
% Make an img and an mat directory to save resulting ROIs
mkdir(‘img’);
mkdir(‘mat’);
% Go through each set of coordinates from the specified file (line 2)
spherelistrows = length(spherelist(:,1));
for spherenumbers = 1:spherelistrows
% maximum is specified as the centre of the sphere in mm in MNI space
maximum = spherelist(spherenumbers,1:3);
sphere_centre = maximum;
sphere_radius = radiusmm;
sphere_roi = maroi_sphere(struct(‘centre’, sphere_centre, …
‘radius’, sphere_radius));

% Define sphere name using coordinates
coordsx = num2str(maximum(1));
coordsy = num2str(maximum(2));
coordsz = num2str(maximum(3));
spherelabel = sprintf(‘%s_%s_%s’, coordsx, coordsy, coordsz);
sphere_roi = label(sphere_roi, spherelabel);

% save ROI as MarsBaR ROI file
saveroi(sphere_roi, fullfile(roi_dir_mat, sprintf(‘%dmmsphere_%s_roi.mat’,…
radiusmm, spherelabel)));
% Save as image
save_as_image(sphere_roi, fullfile(roi_dir_img, sprintf(‘%dmmsphere_%s_roi.img’,…
radiusmm, spherelabel)));
end

UPDATE: WordPress messed with the characters in the above script, so here is a link to the script file and an example spherelist.txt file.

Dropbox is a fantastically versatile piece of software based on seamless integration of user-defined folders with ‘the cloud‘.  Much has been written about how it can be used for general computing, e.g. from Lifehacker:

…Dropbox instantaneously backs up and syncs your files over the internet and to any computer. After you install the application, it will create a Dropbox folder on your hard drive. Any file you put inside that folder will automatically be synced and monitored for changes, and each time a change is saved, it backs up and syncs the file again. Even better, Dropbox does revision history, so if you accidentally saved a file and wanted to revert to an old version or deleted a file, Dropbox can recover any previous version.

It also has some nice collaborative features that allow you to share documents you’re working on, pushing updated versions out to all synchronised dropbox directories as changes are made.  Crucially, whenever dropbox detects a connection to the internet, it synchronises all the files contained within the cloud-synched directories, but it doesn’t require an internet connection to work on those files.  This feature has revolutionised the way I programme, debug and transport participant data from psychological experiments.

Programming Experiments: I, like most psychologists I know, don’t programme my experiments on the machines on which I test participants.  I have a workhorse desktop machine on which I programme, and I use a number of lower-specced machines to gather data.  For instance, I have an fMRI-dedicated laptop which I take to and from the scanner, from which I present stimuli to participants, and on which I store their behavioral data in transit.

I don’t programme on the fMRI laptop because I don’t like spending lots of time working on the cramped keyboard, touchpad and small screen, and because I try and keep the number of applications installed on the machine to a minimum.  A problem arises when I need to test my programming to make sure that: a) it runs on the fMRI laptop; and b) what I have programmed on my 1920×1200 monitor translates well to presentation on 1024×768, the resolution I set the laptop to to be compatible with the scanner projection system.

It’s easy enough to save the experiment and all of its associated files onto a memory stick and transfer them to the laptop whenever I need to test it, but it’s a hassle; one that dropbox eliminates.

I have dropbox installed on both my desktop machine and the fMRI laptop.  When programming, I just set the laptop up next to my desktop keyboard and create an ‘experiment’ directory in my dropbox using my desktop.  I then programme as normal, using my desktop to edit picture stimuli using GIMP and generate instruction slides using Powerpoint, saving everything into the ‘experiment’ directory.  When it comes to testing the experiment, I simply turn to the laptop, where I find all the experiment files have been updated in real-time over wifi.  Perfect! If I run the experiment on the laptop and find that some of the images I’m using are the wrong size I can simply resize them on the desktop and try again, no memory stick required.  I’m able to debug a lot more efficiently like this – it places far less working memory load on me as I can make the required changes as I notice them, rather than once I’ve run through the entire experiment.

Running the Experiment and Transporting Participant Data: I’ve already mentioned that I turn off the laptop’s wifi connection at the scanner.  I also exit the dropbox application (which runs in the background and coordinates the cloud-synching.  The beauty of the system is that all your dropbox files remain available locally when internet connections aren’t available.  I can still run my Matlab scripts and collect data into the dropbox directory.  As soon as I’ve finished testing, I start the dropbox application and enable the wifi connection and the new participant data gets uploaded to the cloud and pushed out to my desktop machine.  Just like that, the data is backed-up and transported to my desktop.  Again, no memory stick required.

This is just one domain of my day-to-day work that dropbox has changed for the better.  I also use the dropbox ‘Public Link’ capability to make my CV available on the web.  Instead of sending my CV to each web-site that wants to host it (e.g. the Dobbins lab website), I now provide a link to the CV in the ‘Public’ folder of my dropbox.  Whilst this difference might seem trivial, it enables me to update my web-based CV in real-time without having to e-mail the administrator of each web-site with an attachment each time I want a change pushed out.

I’m sure there are many other uses I have yet to discover and that’s the beauty of such a straightforward yet polished technology.

WARNING: When you install dropbox, you give it control over everything you put in your dropbox folder – you have to be aware that all changes made to files in your dropbox on one machine will instantaneously get pushed out to all your other machines.
Use antivirus software. If a virus makes its way into any file on your dropbox, it will get pushed out to all the other computers synced to your account.
Be disciplined about backing up your files, even cloud-synced files. Protect youself against the accidental deletion of files in your dropbox.  Once they are deleted on one machine, they will get deleted on all your other dropbox-synced computers.  I have a recurring nightmare where I lose my experiment data because it gets deleted on the fMRI laptop (e.g. it gets stolen and prior to selling it on, the thief deletes everything in the ‘My Dropbox’ folder).  Because I have a nightly backup running, this wouldn’t be terminal, but the prospect of it happening is still scary.



I have been particularly impressed with the way certain corporation have adopted the use of twitter in ways that are beneficial to their customers and potential customers.  Companies I follow that spring to mind include VodafoneUK, LogMeIn and most recently, CharterCom.  Here’s why.

A friend of mine, singlesoliloquy, was having problems with Charter, our local cable company. This morning, after what appears to have been a frustrating call to their call-centre, he tweeted the following:

singlesoliloquy #Charter is charging me to send a new paper statement, because their online billing is malfunctioning. Awesome.

I responded in a manner that was maybe a little more pointed than it needed to be, driven by my own prior problems with Charter.

akiraoconnor @singlesoliloquy OK – I am starting to see why you hate mail, especially when @CharterCom are involved

Which lead to the following response from a Charter representative:

CharterJosh @akiraoconnor @singlesoliloquy @charter Don’t like to hear that at all! What’s up w/ the online billing? Should be waived if our mistake!

and resulted in the following exchange

singlesoliloquy @CharterJosh I can’t access my current statement, due to an error with @charter‘s system. Spent 10 mins chatting, 10 mins on phone.
singlesoliloquy @CharterJosh The solution was send me a new paper bill, charge me a couple bucks processing, do nothing about the online glitch.

CharterJosh @singlesoliloquy Definitely not what should be happening. If you DM the Name/Phone# on the acct I’ll make sure the fee is waived. Can also
CharterJosh @singlesoliloquy work on getting the error fixed too.

finishing up with smiles all round.

singlesoliloquy @CharterJosh Thanks!

akiraoconnor Thanks @CharterJosh! This is why I love #twitter and corporations who use it well.

CharterJosh @akiraoconnor @singlesoliloquy Thanks! We definitely appreciate the feedback. :)

singlesoliloquy has had his charges cancelled and Charter have gone up in my estimation.  Sure, the issue should have been involved satisfactorily with singlesoliloquy‘s call to the call-centre,  but it wasn’t, so it’s great that Charter have another system in place to catch and remedy the grievances of disgruntled customers.

For me, this highlights the way in which Charter, and other twitter-savvy corporations, recognise the way in which their reputation rises and falls on the tide of public perception.  Phonecalls to call-centres are closed loops and so don’t have the potential for corporate embarrassment that Google-indexed tweets do.  Charter are managing their reputation well by responding to publicly-accessible grievances in a manner that satisfies the aggrieved.  It’s just a shame that only tech-literate, twitter-users feel the benefit.  All that remains is for the call-centre managers and staff to have the appropriate foresight and administrative rights to be able to prevent these little fires before their twitter-based colleagues get the opportunity to put them out.

In September we will be leaving St. Louis and moving back across the Atlantic to St. Andrews, Scotland.

Maersk Line Ship

Unlike when we made the move over here in 2008, my new job is contributing towards the cost of relocation, which means flights, temporary accommodation and the shipping of our personal effects should all be paid for.  Being able to take our stuff back with us is a huge deal.  In 2008, we paid for the move ourselves and as a result only shipped three tea-chest-size boxes (using Seven Seas Worldwide, an excess baggage company who I wholeheartedly recommend for small shipments).  These boxes contained only our luxury items – my mother’s old Nikon, some photograph albums, electronic bits and pieces and assorted Kiwiana – meaning that we still needed to spend a great deal of effort and money acquiring furniture, cooking utensils and other household essentials.  This time we can afford to be a little less conservative in what we decide to take with us, which should save us money when we arrive and provide our 19-month old son with a little continuity to his own toy-filled world.

Which is all great in theory.  But how do you go about organising an international shipment?

Googling “international shipping companies” provides you with a lot of companies who are willing to take your details and will probably hound you every week until you respond to their quotates.  But worryingly, all of these companies’ websites are filled with warnings about the fidelity of ‘other’ companies and worse still, many are littered with the sort of bad grammar and 90s webdesign that makes you think twice about clicking on anything other than the back button.  Google’s aggregation of these web-sites, rather than helping me compare them and find the best, only managed to make me mistrust them all.

After a few weeks of online stumbling, I finally hit upon a genuinely useful website – www.movingscam.com.  The first thing I read on the website was:

“The number one question MovingScam.com receives is “Can you recommend a good moving company?”. If the answer to that question was easy, then there wouldn’t be a reason for maintaining a web site called MovingScam.com”

That resonated with my state of mind at the time, so I read on, navigating to their international moving page.  Again there were warnings about what to look for in an international moving company, but this time there was a list of four companies recommended by users of the web-site forum.  I contacted them all and three got back to me with a quote.  We eventually settled on Sterling International, whose representative, Phil Aeschleman, filled me with confidence when he beat me to the name of my liaison at the University of St. Andrews (suggesting that he hadn’t been full of hot air, as I had cynically imagined, when he had earlier mentioned that they were in the process of organising another move from the US to St. Andrews).

We had our pre-move survey yesterday, with our move scheduled for early September.  The prospect of a team of professional movers packing our belongings is a little strange, but it should certainly be efficient.  I hope that in a few months I will be able to contribute to the movingscam forum with a endorsement of Sterling International.  Fingers crossed.

Only 80% of scheduled participants produce datasets where data from all runs is usable.  That’s the conclusion I have drawn from my limited experience of scanning participants for research here at Washington University.

My running totals
Study 1: Usable data from 19 participants  of 24 booked – 79%
Study 2: Usable data from 14 participants of 17 booked –  82%
Study 3 (so far): Usable data  from 6 participants of 8 booked – 75%

That’s 39 from 49, approx. 80% overall.

Reasons for unusable data include script and scanner problems, participants performing at or below chance, participants falling asleep, participants needing to end the experiment early, and participants failing to show up at all.  The participant no-show scenario isn’t really too much of a problem if you are billed only for the time used on the scanner (which is what happens here) though it is rearing its ugly head for me as I am coming to the end of my time here at Washington University – every absent participant reduces my sample size by one.

All of which means, the 20 slots I was counting on for Study 3 should yield a sample of 16 – I reckon that’s on the low end of fine, but still fine.  We’ll see.

fMRI scans produce an awful lot of data.  Depending on whether you’re getting you scanner to output 3D or 4D data, you can end up with one file per measurement, or file per scan.  If you’re dealing with 3D data (the one files per measurement option), you’re in for a long night if you decide that you don’t like the existing file-naming convention, and want to replace it with something a little simpler e.g. if you want to remove unique identifiers to allow for batch processing .  For example, the experiment I’m testing right now collects 292 measurements in each of its five functional scans, that’s 1460 files in total.  If it only takes me a three seconds to rename a file manually, then it’ll still take me over an hour to finish, and that’s just for one participant.

Of course, you could script something to do this pretty quickly, there’s an even easier way: Ant Renamer.

With a few clicks, you can select all the files within a folder (and its subfolders) and carry out a pretty versatile range of file renaming tasks in seconds – it takes about 5 seconds to rename 1460 files once I tell Ant Renamer what to do.  I use it to remove unique identifiers from fMRI data filenames, but the options are there to delete the first x characters from a file, change the extension, add incremental numbers to filenames, even use MP3 metadata to rename MP3s.

Ant Renamer is well worth investigating if you ever find yourself daunted by the prospect of file renaming in bulk – I’ve found it so useful that I keep a portable copy (no install required) on my dropbox so that I can access it on the move.

I’m fortunate in that I have my own office.  If things get noisy, in the lab, I can shut my door.  In fact, to avoid the social awkwardness of shutting my door on lab-mates mid conversation (when they’re talking with each other, not to me, that would be plain rude!) I tend to keep the door to my office closed, or only slightly ajar, at all times.

I’m also fortunate in that I am able to listen to music I know without being distracted.  If the door isn’t holding back the tide of free-flowing conversation, I can usually put on an album I like, turn up the music and just get on with it.

But there’s a problem – my office neighbours the experiment testing room.

If there are participants in there making responses ‘as quickly and as accurately as possible’, they won’t appreciate Tom McRae’s latest album leaking into their consciousness (probably just as much as they don’t appreciate folks talking outside the testing room).  In that special case, I’ve found that non-musical white noise (and its variations) works best.  It’s perfect at masking out distracting conversation and it doesn’t carry.  I’ve had it up at deafening levels when I’m sat in front of my computer, but as soon as I head out into the communal area of the lab, it registers barely a whisper.

“Noise, that sounds amazing.  From where can I purchase such a technology?” I hear you gasping.  Well, rather predictably if you consider the bits and pieces I tend to write about on this blog, it’s free and available online (no download required) at:

http://simplynoise.com/

One of the nice features of the newly re-designed simply noise website is that you can choose your poison: white noise, brown noise, pink noise.  These different varieties of noise have different frequency spectra that impart a slightly different feel to each: white noise sounding tinnier than the other two, with pink noise sounding quite like steady monsoon rain and brown noise like the rumble of distant ocean.  You can also set the volume to rise and fall (though that does leave open the tendency for chitter-chatter from outside to creep in at the low volume points) if you fancy a little more variation in the sound.

If course, if you’re into a more naturalistic noise, you can try:

http://www.rainymood.com/

It sounds just like a rainstorm because that’s exactly what it is – a high quality loop of a storm complete with rolling thunder.  (On the occasions that I’ve turned the volume right up,  I have noticed that you can make out something that sounds a little like distant music – maybe it’s just distortion but I imagine it could be touch distracting if you were bothered by that sort of thing, in which case you’re probably best off sticking to the uniformity of simplynoise.com.)

It goes without saying that this sort of noise can be useful in a number of different ways.  I was initially turned onto it by a friend who does research into auditory perception and since using it myself, I’ve found out about new parents who swear by it for getting their babies (and themselves) to sleep (simplynoise.com even comes with a sleep timer for this very purpose).

Give it a go if you can’t work and listen to music, or if you find yourself in a situation where music just won’t do.

Over the past few months I’ve seen a few fantastic videos on youtube.

Embrace Life – Sussex Road Safety Ad

[youtube=http://www.youtube.com/watch?v=h-8PBx7isoM&rel=0&color1=0xb1b1b1&color2=0xd0d0d0&hl=en_GB&feature=player_embedded&fs=1]

Google Search Stories – Paris

[youtube=http://www.youtube.com/watch?v=nnsSUqgkDwU&hl=en_US&fs=1]

There’s also the Graduation one.

Stephen Walter’s Map of London

Not a video, but an interactive and stunningly detailed and personal map of the city I grew up in.

Maybe the best team goal I have ever seen

[youtube=http://www.youtube.com/watch?v=Y5QbQYJnRYA&hl=en_US&fs=1]

from the friendly between Spain and Poland prior to this year’s World Cup, which Spain went on to win.


We all know about them – those legendary articles that transcend their fields and attain status as  ‘compulsory annual reading for scientists.’  Their ideologies are pure, their arguments are well reasoned and their applications are manifold.  Unfortunately, a small class of these articles maintain their theoretical impact because their practical impact is minimal, at least in certain fields.  Whilst reading these masterpieces, we love them, but when we get back to work, we find it all too easy to slip into our bad old habits, comfortable in the knowledge that we know the principles of science even if the current project doesn’t best embody them.

Yesterday I read Strong Inference, an 8-page article by (bio)physicist John R. Platt published in Science in 1964 (doi:10.1126/science.146.3642.347).  I don’t know if  I was reading it for the first time, or if I had done so previously for an undergraduate Philosophy of Psychology class.  Either way, I found coming across it and taking the time to read it (again) to be thoroughly invigorating.  The basic argument is the Popperian tenet that there is no value in proof because data can prove multiple theories, there is only value in disproof and the subsequent disregard of the disproved theory.  In the article, Platt supports this thesis by outlining a number of methods that afford this form of ‘strong inference’.  These methods include an at first surprising dismissal of the testing of quantitatively distinct hypotheses in favour of testing qualitatively distinct hypotheses.

“Many-perhaps most-of the great issues of science are qualitative, not quantitative, even in physics and chemistry.  Equations and measurements are useful when and only when they are related to proof; but proof or disproof comes first and is in fact strongest when it is absolutely convincing without any quantitative measurement.”
That is, it is far more compelling to adjudicate between two theories that make qualitatively different predictions about phenomenon X (e.g. according to theory A, X will rise, but according to theory B, X will fall) than it is to adjudicate between theories that make quantitatively different predictions that differ only by degree (e.g. according to theory A, X will rise by 10, but according to theory B, X will rise by 20).

Reading the article provided an  invigorating experience.  It filled me with a ‘wonder of first-principles’ – a delight in the understanding of how and why something works – and it reminded me that the power of falsification forms the foundations of the scientific method.  Then, when I examined my own position in relation to the article, and I found it less invigorating and a little more thought-provoking.  I thought back to the situations where I lost sight of the goal of falsification and was content with trying to find evidence and a compelling argument to support a sensible idea… not a sin in itself, but it doesn’t represent strong inference as outlined by Platt.  To take the metaphor of foundations further, maybe a house is first built over strong foundations, but as it expands it needs to stay true to those foundations. If it expands outwards and builds on its own structure without regard for whether or not the extensions are supported by the foundations, it will eventually display a very noticeable lack of structural integrity.

It is easy to spot that lack of structural integrity in the arguments of others, especially when they take a stance against your own position.  It’s why we hate Reviewer 2 so much – “Of course he was going to recommend rejection” I might say, “How can he devote his career to Theory A when it’s totally inconsistent with finding F and any argument he makes to accommodate it makes his theory unfalsifiable?”  But I must apply these same standards to my own research.  What theories do my findings disprove? “Why am I still considering theory B,” I should also be saying, “when finding G and the H-effect disproved it nearly 20 years ago?” But of course this kind of self-critical thinking is uncomfortable for all of us, especially when we find ourselves to be (occasional) hypocrites.

Maybe for this reason, this  kind of self-examination has not taken hold in many fields of Psychology – it’s just too painful.  And unfortunately, that is why Platt’s article still carries such weight.  I look forward to a time when I can recommend it to my PhD students, not because it reminds them of the oft-forgotten founding principles of Psychology, but because it reinforces their commitment to the problem-oriented method that will guide their successful careers in science.

One of the most annoying and stressful things that can happen during an fMRI experiment is for system notifications, pop-ups or even the Windows taskbar to suddenly appear on the screen on which you are presenting stimuli to participants.  Here I outline a few things that I do to minimise the likelihood of this sort of disruption when running Matlab on a Windows XP machine.

1) Turn off your wireless network adapter. This reduces the processing burden on your system – crucial if you’re interested in measuring response times – and stops a lot of annoyances (Flash updates, Windows updates etc.) being pushed to your system.  My laptop has a manual switch on the exterior than I can flick to turn it off.  Alternatively, the wireless network can be disabled within windows by navigating Network Connections, right-clicking on the wireless network, and selecting ‘disable’.

2) Disable Real-Time Antivirus Protection and Windows Automatic Updates. This again reduces the burden on your system  and stops annoying notifications popping up.  Whatever it is, it can wait.  However, disabling real-time protection  will probably lead to an ugly warning in your system tray, but no-one needs to see that if you…

3) Turn off the ‘always on top’ property of the Windows Taskbar. Once you do this, Matlab will sit entirely on top of the taskbar, and the taskbar shouldn’t ever become visible at inopportune moments (something I inexplicable struggled with when designing my latest fMRI experiment).  Right click on the taskbar, select Properties, and untick the ‘Keep the taskbar on top of other windows’ checkbox.

4) Disable balloon tips in the notification area. Whilst you could turn off the system tray altogether, that shouldn’t be necessary if you’ve already followed step 3.  (One reason I like to keep the system tray visible is that I find it a handy way to t manage wireless networks, Dropbox, etc. and I don’t want to lose that functionality entirely. ) However, to reduce the chances of anything else you haven’t already thought of ‘helpfully’ reminding you of something mid-experiment, turn off bubble notifications, as detailed in this Microsoft TechNet article.

That should give you the best crack at getting through an experiment with an ugly, flickering, Windows interruption.  Now that you’ve covered your bases,  all you need to do is make sure that your Matlab coding doesn’t give you any  grief – easier said than done.

UPDATE: These steps aren’t exclusive to Matlab stimulus presention either.  They could give you peace of mind before hooking your laptop up to give a formal presentation or jobtalk on Powerpoint… I’ve seen too many talks interrupted by pesky Windows Update notifications and ‘Found new wireless network’ bubbles.