eXTReMe Tracker
Apr 232015
Dining Area Kitchen Kitchen Dining Area Porch Backyard Backyard From the backyard Porch Kitchen Living and Kitchen capecod012 Staircase Master Bedroom Guest Bedroom Guest Bedroom Front Landing Living Area Staircase Staircase Garage Garage Garage Garage Basement - Den and Bedroom Basement den Basement den Below the staircase Two car garage Some sectioned out places in yard From the edge From the edge Guest Bath Guest Bath Bath Bath Bath Master Bed Master Bed Master Bed Door Street View Street View Front Door
Dining Area
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.

Sep 162014

Every once in a while as you are trying to make a .iso file from a DVD using Brasero, you might get an error saying that couldn’t retrieve the keys because of libdvdscc2.

An alternative to that is a command line tool called dvdbackup which first needs to be installed

sudo apt-get install dvdbackup

After installing that program, you can make backup of your entire dvd, unfortunately not an .iso. You can create an iso from the folder that gets generated once you backup the dvd using dvdbackup. To create a backup, open your terminal and run:

 dvdbackup -M -i /path/to/dvd/  -n Title_For_Backup -o /path/to/output/directory

To get help of dvdbackup you simply have to type in dvdbackup at the terminal.

Sep 252013

Before making any modification to any files, first create a backup of smb.conf file

sudo cp /etc/samba/smb.conf  /etc/samba/smb.conf.bak

The open the configuration file for editing:

sudo gedit /etc/samba/smb.conf

In the section identified as Share Definitions, insert this piece of code. The path string should be the path for folder you will be sharing. If you want others to have the ability to write to that directory –

sudo mkdir -p /path/to/shared/folder
sudo chown nobody.nogroup /path/to/shared/folder
    comment = Ubuntu File Server Share
    path = /path/to/shared/folder
    browsable = yes
    guest ok = no
    read only = no
    create mask = 0755

Once the configuration file has been saved, its time to restart the samba daemon

sudo restart smbd
sudo restart nmbd

Once the samba daemon has restarted, you need to add a list of users who can access samba folder.

sudo smbpasswd -a username

To access this directory from windows, open My Computer -> Tools -> Map Network Drive

Folder address for this share would be:


NOTE: The folder is called share in the share definition. You can call it something else and edit the parameters based on the chosen share name.If you want to have access to this folder each time, make sure to save the password and check that option to reconnect at login.



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