Solution to “Can’t Select Airplay Device for Output Audio”

In terminal run this,

sudo kill `ps -ax | grep ‘coreaudiod’ | grep ‘sbin’ |awk ‘{print $1}’`

Posted in Uncategorized | Leave a comment

Converter to find PMCID and NIHMSID from PMID

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.

Posted in Uncategorized | Tagged | Leave a comment

My best friends: awk & sed

Two very powerful friends to have for all sorts of scripting using BASH: awk and sed – never enough said.

E.g., awk -F option, powerful tool to cut the high grass of structured logs. Similarly, sed with the \1, \2, … parameters super powerful for remembering and replacing text with ease. 

big fan :-)

Posted in Uncategorized | Tagged | Leave a comment

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

Posted in Uncategorized | Tagged , | Leave a comment

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.

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

Posted in Uncategorized | Tagged , , , | Leave a comment

BASH: How to remove return char in output and how to print tabs in output

Use -n option for removing return character in output

Use -e option to print the tabs or other sequences in output


Command: for f in {1..20}; do echo -n -e “hello\t”; done 
Output: hello     hello      hello      hello

Posted in Uncategorized | Tagged , | Leave a comment

Semi-autoMatic Artifact Removal Tool (SMART)

SMART was developed during my dissertation work at the University of Texas at Austin. The idea was to preprocess electroencephalogram (EEG) data that was collected while participants meditated with their eyes closed. EEG is infamous for getting easily corrupted by muscular and other artifactual sources of noise. Thus, we used a two step process of pre-processing EEG data. First, we used second-order blind source separation to find sources that were uncorrelated in time (hence second-order). Second, we developed a novel semi-automatic web-based tool (or SMART) to identify non-neural sources of artifact (e.g., muscular artifact, ocular artifact, and  interference by power lines).

The identification of artifacts was done in SMART by using three key pieces of information – topological, temporal (mainly auto-correlation function), and spectral structure of each component. Based on simple rules, first SMART identified sources as different kinds of artifacts. Followed by generating a web-based tool, so that the researcher can quickly and efficiently go over all the components and their corresponding properties to judge whether SMART correctly classified the source under consideration as noise or not. If not, then the researcher can override source’s classification by clicking a radio button. The screenshot below better portrays the point.

The source code is provided here. For more information on the SMART tool, please see the following references. Also, if you use this tool in your research, please cite these as well.

  1. Saggar M, et al. (2012) Intensive training induces longitudinal changes in meditation state-related EEG oscillatory activity.   Front. Hum. Neurosci. 6:256. doi: 10.3389/fnhum.2012.00256
  2. Saggar, M. (2011) Computational analysis of meditation. Retrieved from University of Texas Digital Repository: Electronic Theses and Dissertations, (Austin, TX), Pages: 24-44.

NOTE: SMART for other imaging modalities (fMRI and fNIRS) is under testing and will be released very soon.

Posted in Uncategorized | Tagged , , , , , , | Leave a comment

Renaming multiple files in Unix (or Mac)

Say you have all your files named ABC_something_numbered.nii.gz and you want to rename all these files as ABC_somethingelse_numbered.nii.gz. Here is how you can achieve that in a single command

for f in ABC_*; do mv “$f” “${f/something/somethingelse}”;done

Note: if you have the rename package installed, you can use that instead.

Hope that helps!

Posted in Uncategorized | Tagged , , | Leave a comment

Using Parallel Computation Toolbox from Matlab

If you have the Parallel Computation Toolbox (PCT) from Matlab, you can use its power and ease of use to run neuroimaging analysis in parallel. Read more here and here for more information on this toolbox. The trick is to use multiple CPU cores on your machine for running analysis in parallel. For example, when I am running some analysis on every participant, I can use PCT to launch the analysis on 6-8 participants in parallel, which cuts down the run time to about 5 times or so.

To use this toolbox, first open the matlab pool as follows

matlabpool open  % to use all the available CPU cores OR

matlabpool open 2 % to open just two of them

Then just  change the for loop (e.g., over each participant) to

parfor p = 1:1:npart

% calculation here


And closing the pool in the end,

matlabpool close;


Hope that helps!

Posted in matlab, unix | Tagged , , | Leave a comment

Cool Python tutorials by Google

Check out  Google’s Python Classes – very easy and neat way of learning Python for all kinds of beginners (especially Neuroimagers – since Python is the future :D). These classes were taught by Nick Parlante  – Many thanks to Nick :)

I have embedded the videos below (from YouTube) for ease and here is the link to the exercises (as referred in the tutorials)

Tut 1 – Introduction, strings

Tut 2 – Lists and sorting

Tut 3 – Dicts and files

Tut 4 – Regular expressions

Tut 5 – Utilities

Tut 6 – Utilities urllib

Tut 7 – Conclusions

Posted in unix | Tagged , , | 1 Comment