Calculating average over column in bash

For data analysis, there is sometimes a need for calculating average over columns (from a text file, e.g., motion parameter file in fMRI data analysis). Awk presents a quick solution for such needs:

Code for averaging over the first column of a file (hence $1 below):

cat <filename> | awk '{total += $1; count++} END {print total/count}'

2014 in review

The WordPress.com stats helper monkeys prepared a 2014 annual report for this blog.

Here’s an excerpt:

A San Francisco cable car holds 60 people. This blog was viewed about 3,100 times in 2014. If it were a cable car, it would take about 52 trips to carry that many people.

Click here to see the complete report.

How to copy text from a Word Document with Track Changes

If you ever wanted to copy text from a word document, while also copying the tracked changes, you are in luck (thanks to this blog entry).

The command for Windows/Mac as follows:
(1) Mac:

  • Select the text (with track changes) and press command + fn + F3 to CUT  the text and then select the window you want to paste the text into and press: command + fn + shift + F3.

(2) Windows:

  • Select the text (with track changes) and press Ctrl + F3 to CUT  the text and then select the window you want to paste the text into and press: Ctrl + shift + F3 to paste.

 

How to rotate the built-in screen of iMac or other newer macs

I wanted to rotate the screen of my work iMac by 90 degrees, so that I can enjoy my vertical monitor setup from home and VNC (remote screen) into work iMac. After a lot of search, I found that the built-in display settings, to change the rotation, is not available in iMac. Even the “option” + “cmd” key press, while clicking on Display (under system preferences) didn’t work on my iMac [Note: it did work on my MacBook Pro, though]. So I installed the SwitchResX software and voila the screen can be rotated [Note: you might need to install the helper functions and change the rotation using the monitor icon in the task bar]

Converter to find PMCID and NIHMSID from PMID

PMCID/PMID/NIHMSID Converter
Given a set of PubMed IDs (PMIDs) you can use this converter to obtain the corresponding PMCIDs and/or NIHMS IDs if they exist. A PMCID will be available if the article is in PubMed Central (PMC). An NIHMS ID will be available if the manuscript has been deposited via the NIH Manuscript Submission (NIHMS) system. The tool is able to process maximum 2000 IDs in a single retrieval. If you have a larger number of IDs, split your list into smaller subsets for consecutive retrievals.

http://www.ncbi.nlm.nih.gov/pmc/pmctopmid/

Issue: Spell check not working in Microsoft Word

For some reason the spell check was not working in my word document and I didn’t know how to fix it. A quick Google search helped and here is the solution that worked for me,

(1) Select all the text in your document (ctrl+A or command+A)
(2) Click on Tools->Language
(3) Make sure the “Do not check spelling or grammar” is unchecked (it could be showing a minus sign, click on it twice to make it unchecked.
(4) Voila!!! fixed 

For more information on this issue or if the above solution doesn’t work, see here

NEUROIMAGING: how to extract brain from T1w images using AFNI

I am a big fan of FSL. However, the brain extraction tool (BET) is not very user friendly at times – especially in terms of finding the perfect parameters for “fractional intensity threshold” and “vertical gradient in fractional intensity threshold”. Luckily I recently learned how to use AFNI for the same purpose and found it very robust among different kind of scans (or data from different scanners). Best of all, no parameter to set.

Commands: 
3dSkullStrip -input ${anat}.nii.gz -o_ply ${anat}_surf.nii.gz
3dcalc -a ${anat}.nii.gz -b ${anat}_surf.nii.gz -expr ‘a*step(b)’ -prefix ${anat}_brain.nii.gz