eXTReMe Tracker
Jul 312015

If gnome-do fails to locate and launch terminal (or gnome-terminal), it is because of a small omission in the gnome-desktop.terminal file.

In terminal run:

locate gnome-desktop.terminal

Once you find that file, open it using nano or gedit with sudo.

sudo nano /usr/share/applications/gnome-terminal.desktop

Search for the line that says:


Add X-Cinnamon to the end of that line such that it reads.


That’s it. Once you log out and log back in, terminal will start appearing as one of the search results in gnome-do.

May 272015

In Linux Mint 16 and 17, there is a small bug in gnome-do. Well, techincally it is in a file called gnome-terminal.desktop

Searching for terminal in gnome-do in Cinnamon environment gives no results for gnome-terminal. The first entry is usually Printers. This is caused because of an omission in the gnome-terminal.desktop file.

Open terminal by searching through start menu:

locate gnome-terminal.desktop

You will usually find it at: /usr/share/applications/gnome-terminal.desktop

sudo nano /usr/share/applications/gnome-terminal.desktop

Find the line that says:


To that list add X-Cinnamon so it will read.


Save the file and log out. Once you login again, terminal should appear on top of Gnome-do search as soon as you type t.

Dec 222014

The purpose is to to convert a 3-dimensional image file which contains X,Y and the dimensions containing RGB values to a 2D image file in grayscale. It can be done in linux command line using imagemagick.

convert <img_in> -set colorspace Gray -separate -average <img_out>

The resulting image is a 2D image generated by averaging the R,G,B arrays.

Dec 152014

Converting nifti files to dicom using nifti toolbox in matlab

clear; clc;
 [dicomfile, dicompath] = uigetfile('*.dcm','Select DICOM header for metadata');
 metadata = dicominfo(fullfile(dicompath, dicomfile));
 metadataISAS=metadata; metadataMPR=metadata; metadataFUS=metadata;
 metadataMPR.SeriesDescription = 'SAG_MPRAGE_T1_Recon'; metadataMPR.SeriesNumber = 1;
 metadataISAS.SeriesDescription = 'ISAS Hyperperfusion'; metadataISAS.SeriesNumber = 2;
 metadataFUS.SeriesDescription = 'MPRAGE ISAS Fusion'; metadataFUS.SeriesNumber = 3;
 isas = uigetfile('hyper*.nii','Select hyperpefusion file');
 structural = uigetfile('mprage*.nii','Select MPRAGE');
 isas = load_untouch_nii(isas); isas = isas.img; isas = int16(isas);
 structural = load_untouch_nii(structural); structural = structural.img;
 display('... Merging Hyperperfusion and MPRAGE');
 merged = structural;
 merged(isas>0) = max(max(max(structural)))+10;
 display('... Finished Merging')
 isasdir = fullfile(subjectdir,'isas');
 if exist(isasdir) ~= 7
     mkdir(fullfile(isasdir,'SPECT_ISAS')); spectdir = fullfile(isasdir,'SPECT_ISAS');
     mkdir(fullfile(isasdir,'structural')); structdir = fullfile(isasdir,'structural');
     mkdir(fullfile(isasdir,'fusion')); fusiondir = fullfile(isasdir,'fusion');
 % dicomwrite(reshape(x4,[170,256,1,256]), 'SPECT_ISAS.dcm', metadata, 'CreateMode', 'copy');
 display('... Creating DICOMS');
 for slicenum = 1:size(isas,1)
     cd(spectdir); metadataISAS.InstanceNumber = slicenum;
     dicomwrite(fliplr(rot90(squeeze(isas(slicenum,:,:)))), sprintf('SPECT_ISAS_%03d.dcm',slicenum), metadataISAS, 'CreateMode', 'copy');
     cd(structdir); metadataMPR.InstanceNumber = slicenum;
     dicomwrite(fliplr(rot90(squeeze(structural(slicenum,:,:)))), sprintf('structural_%03d.dcm',slicenum), metadataMPR, 'CreateMode', 'copy');
     cd(fusiondir); metadataFUS.InstanceNumber = slicenum;
     dicomwrite(fliplr(rot90(squeeze(merged(slicenum,:,:)))), sprintf('FUSION_MPR_ISAS_%03d.dcm',slicenum), metadataFUS, 'CreateMode', 'copy');
     display(sprintf('... Creating slice %d',slicenum))
Oct 232014

To compute a transpose of an input file, i.e. converting columns to rows and rows to column using bash, you can accomplish that using awk and while loop.

cols=`cat $1 | head -1 | wc -w`;
for i in $(seq 1 $cols);
awk -v "n=$i" '{print $n}' $1 | tr '\n' ' ';  # variable column output
printf "\n";

This example uses a variable to output a specific column from the input.

awk -v "n=$variable" '{print $n} ' input.txt

Will pass the variable to n and the nth column gets printed from input file.

Aug 212013

If the gnome/mate/cinnamon session becomes unresponsive, you can use the Ctrl+Alt+F1 key sequence to get to shell mode. Once there,  you can login and run the following command to end the graphical session:

sudo pkill -KILL -u USER_NAME
Jan 112013

To get the stock quotes for NYSE listings create some file named stockval and add it to your PATH.

Then gedit the file with the text:


p=`printf "curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=$1&f=l1'"`
price=`eval $p`;
echo $price












Make that file executable

chmod +x stockval

Close out, and open a terminal. If you have the path correctly configured, execute the stockval command using the company symbol as an argument and it returns the stock price on the line below.

stockval goog

732.15 << output
Oct 292012

As it turns out the if statement in bash isn’t as friendly towards floating point variables as it is for integer and string variables.

First of all the -gt and -lt switches don’t work.Even the unary operators >,<, etc. don’t work. The only way is to do a comparison between the floating point variables using bc and using the logical outout as a comparison string.

a=11.5; b=11.3
compare_result=`echo "$a >$b" | bc`
 if [ $compare_result -gt 0 ]; then
 echo $a
echo $b