eXTReMe Tracker
Mar 302011
 

FSL: flirt is used to compute an intial affine normalization of the T1 weighted images; this is then fed to fnirt to compute the overall transformation. flirt is also used to register the EPI’s to the subject’s structural image. This was then used along with fnirt-s warp in applywarp to normalize the EPIs.

Script for normalizing the T1-weighted structurals to the template:

Registering T1-structural to MNI152

bet my_structural my_betted_structural
flirt -ref ${FSLDIR}/data/standard/MNI152_T1_2mm_brain -in my_betted_structural -omat my_affine_transf.mat
fnirt –in=my_structural –aff=my_affine_transf.mat –cout=my_nonlinear_transf –config=T1_2_MNI152_2mm
applywarp –ref=${FSLDIR}/data/standard/MNI152_T1_2mm –in=my_structural –warp=my_nonlinear_transf –out=my_warped_structural

Registering functional data to MNI152 (via structural scan)

bet my_structural my_betted_structural
flirt -ref my_betted_structural -in my_functional -dof 7 -omat func2struct.mat
flirt -ref ${FSLDIR}/data/standard/MNI152_T1_2mm_brain -in my_betted_structural -omat my_affine_transf.mat
fnirt –in=my_structural –aff=my_affine_transf.mat –cout=my_nonlinear_transf –config=T1_2_MNI152_2mm
applywarp –ref=${FSLDIR}/data/standard/MNI152_T1_2mm –in=my_functional –warp=my_nonlinear_transf –premat=func2struct.mat –out=my_warped_functional

Mar 172011
 

On the destination computer type the following command. Replaceing middleuser with your name and replacing middle with the domain of the middle computer.

ssh -R 10002:localhost:22 middleuser@middle

This will open port 10002 for listening and forward all future connections to port 22 at destination. This connection must remain on the entire time to ensure that you can access your destination computer whenever you want.

Now if sshd is set to use GatewayPorts you should be able to connect with this:

ssh destinationuser@middle -p 10002

If you are not sure if GatewayPorts is on or you don’t have the access to change it use the following method to connect:

First connect to the middle computer how you would normally.

ssh user@middle

Then connect to the localhost of the middle computer on port 10002.

ssh user@localhost -p 10002

Note: The port 10002 is arbitrary you can use any port you want.

You should now be remotely logged into your computer behind the NAT/Firewall. Enjoy.

Content copied from :http://www.marksanborn.net/howto/bypass-firewall-and-nat-with-reverse-ssh-tunnel/

Mar 152011
 

If you are on a network that has MAC addresses hardwired, i.e. you can only access the network if a certain MAC address is plugged into a specific ethernet jack on the wall, you don’t have too many options.

One option I used recently is spoofing the MAC address of your device. Its done by editing the hardware address to match the MAC address of the device that’s allowed on that ethernet jack.

If you are using Linux, make a note of your current IP address in a text file.

sudo ifconfig -a | grep eth0 > ~/Desktop/netaddressbak.txt

Run the same command on the device that’s attached to the network to find its MAC address: Lets say its – 01:82:39:B2:41:30

Before you attach your new device to the ethernet cable, change its MAC address to the one listed above.

sudo ifconfig eth0 down
sudo ifconfig eth0 hw ether 01:82:39:B2:41:30
sudo ifconfig eth0 up
sudo ifconfig eth0 | grep HWaddr

This should now list the address as 01:82:39:B2:41:30.

You can now attach this device on the network to gain full connectivity (unless there are some programs that are supposed to ping every once in a while).

Mar 142011
 

#!/bin/bash
#$x would be the input filename and %3d will pad it to be a 3 digit number with zero pads, %4d will make it 4 digit and so on.
num=`expr match “$x” ‘[^0-9]*\([0-9]\+\).*’`
paddednum=`printf “%03d” $num`
echo $paddednum

Dec 012010
 

Script to preprocess 4D fMRI time series:

spm_defaults;
 global defaults;
%% Slice Timing
display('Step 1: Slice Timing');
sliceorder = [1:2:17 2:2:16];
 refslice = 17;
 TR = 1;
 precision = 5;
 nslices = length(sliceorder);
P = dir('4Dout*.nii');
 P = char(P.name);
 TA = TR - TR/nslices;
if precision > 0
 TAstr = num2str(TA, precision);
 TA = str2double(TAstr);
 end
timing(1) = TA / (nslices -1);
 timing(2) = TR - TA;
 spm_slice_timing(P, sliceorder, refslice, timing);
%% Realignment and Reslicing
display('Step 2: Realignment');
 P=dir('a4Dout*.nii');
 P=char(P.name);
 FlagsC = struct('quality',1,'fwhm',5,'rtm',1,'interp',1);   %Flags for realignment
 spm_realign(P,FlagsC);
display('Step 3: Reslice');
 %Flags for reslicing
 FlagsR = struct('mask', 1, 'mean', 1,'interp',4,'which',0, 'wrap', defaults.realign.write.wrap);
 spm_reslice(P,FlagsR);
 display('... saving motion parameters as a motion_report.pdf ');
 saveas(gcf, 'motion_report', 'pdf');
 close all;
%% Normalization
display('Step 4: Normalization');
template = fullfile(spm('Dir'),'templates', 'EPI.nii');
 srcimage = 'mean*.nii';
meanimg = dir(srcimage);
 P = char(meanimg.name);
 snmat_name = strrep(P, '.nii', '_sn.mat');
 if exist(snmat_name, 'file')
 disp(['... removing existing file named: ' snmat_name]);
 delete(snmat_name);
 end
 objmask_name = '';
spm_normalise(template, P, snmat_name, defaults.normalise.estimate.weight, objmask_name,defaults.normalise.estimate);
%% Write Normalized Images
display('Step 5: Writing Normalized Images');
PP = dir('a4D*.nii');
 PP = char(PP.name);
 spm_write_sn(PP, snmat_name, defaults.normalise.write);
%% Smoothing
display('Step 6: Smoothing ... ');
PP = dir('wa4D*.nii');
 PP = char(PP.name);
 PP = cellstr(PP);
for list = 1:length(PP)
 Q = strcat('s', PP{list});
 spm_smooth(PP{list}, Q, defaults.smooth.fwhm);
 end
 %display(sprintf('\nPreprocessing compled.\n\nTime taken %d sec.\n', x));
Getting data extracted from time series:
Create ROI maps with WFU Pickatlas and MarsBar.
 Extract the contents of masks by:
 XYZ=struct(roi); XYZ=XYZ.XYZ;
%% Convert XYZ to mm
XYZ=[XYZ; ones(1, size(XYZ,2))]; XYZmm=roi.mat*XYZ; XYZmm(end,:)=[];XYZmm=XYZmm';
%%
p=spm_vol('swaf00xx.nii');
 [time_data]=spm_get_data(p, XYZ);
 time_data=mean(time_data,2);
Apr 202010
 

Some of the countries that had remarkably high data transfer rates were reporting a drop in network speeds as a result of smart phones gaining popularity over the past year or so. Following that train of links, one ends up article after article about which nation ranks first in network speeds, and where US lies on that list and so on. There was one website which gave a really comprehensive set of results and analysis, right till the ISP level for pretty much every nation on the planet.

speedtest.net

Speedtest - Analyze network speeds and compare results

Seems like the site is pretty up to date too.

Apr 192010
 

For the first time I was able to get VNC to work with Ubuntu with Gnome session instead of a xterm on gray background. The steps involved were exactly the same as I was following earlier, with one exception:  the setup of xstartup in the ~/.vnc folder.

For your xstartup file in ~/.vnc (the “.vnc” folder in
your home directory), you need the following:
—————————–
#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &
gnome-session &
# twm &
————————

instead of uncommenting the lines as the script suggests, you change the window manager to gnome-session

make sure restart vnc4server

The line which got Gnome working was “gnome-session &”

========================================

Now for all the steps involved (works in Karmic Koala Alpha 2, Ubuntu 9.10, kernel 2.6.30-10)

1. Install ssh server, ssh client, VNC viewer, VNC server, and xinetd

sudo apt-get install openssh-server openssh-client vnc4server xinetd  vncviewer

2. Setup the ssh password for your login

ssh-keygen

3. Test out the ssh server by typing in

ssh localhost  or ssh your_login@your_ip_address

4. Then create a vnc password

sudo vncpasswd ~/.vncpasswd

5. Edit the xstartup file in ~/.vnc directory

For your xstartup file in ~/.vnc (the “.vnc” folder in
your home directory), you need the following:
—————————–
#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &
gnome-session &
# twm &
————————

instead of uncommenting the lines as the script suggests, you change the window manager to gnome-session

6. Create a VNC desktop

vnc4server :1 -geometry 1024×768

7. Then to tunnel into your VNC desktop, first create a SSH tunnel by logging into SSH with the comand:

ssh -L 5901:your_ip_address:5901 your_username@your_ipaddress

8. Finally, load up your VNC desktop

vncviewer localhost:1

And now you are ready to use connect to your machine remotely and use administer the computer remotely.

P.S: If you are using a firewall (hardware or software, you need to get enable port forwarding and unblock ports 22 and 5900-5999 on the Ubuntu machine to allow SSH and VNC to be accessed.

Mar 092010
 

Ubuntu came out with the Alpha 3 version of Lucid Lynx (Ubuntu 10.04) in the last week of February. The window control buttons (minimize, maximize and close) were still on the right hand side. Then on March 8th, there was a change in metacity. Regardless of which theme you choose, the window controls are seen on the top left hand corner of each window. Its taking me a bit of getting used to. Since I have been using OS-X theme for my windowing, this has come freakishly close to looking like a Mac, and its not good.

Location of controls is switched to left in Lucid Lynx Alpha 3

Location of controls is switched to left in Lucid Lynx Alpha 3

The release is still in its alpha stage. If a lot of people express dissatisfaction at the new placement of these buttons, it might be reverted back to its old location.

ETA: There is a workaround to get the window controls to the desired location.

  • start gconf-editor, go to /apps/metacity/general/button_layout
  • Colon separates what goes in the left corner versus the right. eg:
  • menu:minimize,maximize,close means menu on the left, min max close on the right.

This workaround was found at: http://www.ivankamajic.com/?p=281#comment-30647

Mar 082010
 

In order to convert files in .img and .hdr format to a single .nii file, we first need to install the nifti tools toolbox for matlab.

nifti tools

Once the path for nifti tools has been set in matlab, the files in .hdr and .img format can be combined to create a .nii file by running the following two commands:

nii=load_nii(‘filename_with_hdr_extension’);
save_nii(nii, ‘desired_filename_for_niftifile.nii’);

If you have freesurfer installed, you can convert between the files types with mri_convert by specifying the input (-it) and the output (-ot) type.

mri_convert -i name_of_input_file -it nifti1 -ot nii -o name_of_output_file

If you have functional dataset with several volumes over the course of your experiment, you can use the fslmerge function available in FSL to combine all the nifti files into a single 4D file.

fslmerge -t output_name.nii *.nii

Where *.nii would cover the entire set of nifti files if they are arranged sequentially.

Its not required to type in the extension .hdr or .img for the input image or output image if you have specified the input and the output types. By specifying the input type of nifti1, you tell the program that it will be a .hdr/.img pair, and specifying output type as nii goes for having your output with .nii extension.

To gzip the nifti file for use in freesurfer:

gzip filename.nii filename1.nii.gz

This will create a gzipped nifti file.

To automatically segment the structural volume:

recon_all -i filename1.nii.gz -subjid SUBJID -all

This will segment the structures containing in the structural file filename.nii.gz. Complete information on using recon-all for freesurfer can be found at FreeSurfer Wiki.

For some reason, Freesurfer seems to work well in tcsh. I’ve often encountered problems of weird nature when running it under bash. In order to run your autosegmentation with freesurfer type in tcsh at the terminal, since by default it is set to bash in most linux distros.

Dec 232009
 

A few weeks ago, the Ubuntu development team released the Alpha 1 of their upcoming release, Lucid Lynx. Since most Ubuntu releases are known only by their first name, I’m hoping the term that most people would use to describe this release would be ‘Lucid’ – like, “we just got a printer and we’ll be using it with Lucid over the network.”

The options for upgrading to Alpha 1 are:

1. Clean install from a downloaded .iso for the flavour you are interested in.

2. Upgrade from earlier version – 64-bit Karmic in my case.

I chose the second option, since I didn’t want to lose any of my installed non-open source programs such as Matlab during the installation process. In order to upgrade from Karmic, open up the terminal and type in -

sudo update-manager -d

It will bring up the update manager and you can then see the option of upgrading to a newer distro. You’ll be asked if you’re okay with removing certain packages and upgrading some of the existing ones to which you have to answer ‘yes’. During installation, all of your third party repositories would be disabled. The most commonly used third party repository is the Medibuntu repository, which will be disabled. But don’t worry, after (successful) upgrade, you can re-enable the medibuntu repository for Karmic, since there still isn’t a medibuntu repository for Lucid.

During the upgrade process, be sure not to keep any program running otherwise the system starts freaking out a little. In my case, Firefox 3.5 kept signing me out of my gmail account over and over – so the best thing is to keep all programs closed.

After the upgrade is complete, you’ll be asked to restart the system. Currently, Lucid is running the 2.6.32.9 kernel, and it won’t be too long before it goes on to 2.6.33.xx.

I’ve read elsewhere that Ubuntu 10.04 will be stripping out some of the programs like GIMP from the basic distro. You can of course obtain it from the repositories once you have got the basic system up and running. Some people are quite worked up about it – but the simple fact is it doesn’t take that long to get GIMP or any program on the repositories once you have the network up and running. Now that’s the beauty of upgrading from an earlier version – that way you don’t have to worry about such things. All the programs that you’ve installed, and that are now in the repository, are automatically upgraded to the latest snapshot.

It takes about 45-90 minutes depending upon your processor speed, the network speed, and the number of programs that you’ve installed. After all the upgrades are completed, you’ll also be asked if you want to remove certain packages, and after those are removed, you’ll need to restart the computer for the changes to take effect.

So, on to restarting. When you restart you’ll see a painfully long list of kernels and recovery options. Frankly speaking, once you have the latest kernel working correctly, there is no point in having an entry to an older kernel in the Grub menu. After this reviw, I’ll be posting the way you can remove the items from the grub menu that you won’t be needing.

Now comes the fun part. When you’re booting Lucid (Alpha 1) for the first time, the X is quite likely to be all messed up. But Lucid now has a failsafe option which defaults the graphics to 1024×768 regardless of what your monitor resolution is. But the good thing is that, you have the option to log in using the failsafe mode, and it works quite well too.

After searching for a way to fix the X issue, I finally found out that there is a conflict with the fglrx drivers included in Alpha1. The fix is to remove all the fglrx drivers that have been installed. I forget the name of the package, but its something like xorg-drivers-fglrx.

sudo apt-get remove xorg-drivers-fglrx

(or something similar)

In addition to removing the fglrx drivers, you also need to clear out the xorg.conf file.

sudo gedit /etc/X11/xorg.conf

Just clear out all the lines in there such that it looks like an empty file. Then save it and reboot the computer. This time it boots with proper resolution.

If you were to do a hardware driver search, and in case you have a graphics card – its quite likely that the installation of that graphics card will fail at this point in time. On doing a hardware drivers search, it found the driver for my ATI Radeon card, but it wouldn’t let me install the driver stating some sort of conflict. It will soon be resolved, but as of now I can’t use compiz – no big deal.

Besides this – there was no problem whatsoever. The wireless card work flawlesslessly, the previously installed third party programs from Medibuntu worked well, and even the /home folder settings for all users were preserved.

Graphics wise, there doesn’t seem to be any change. The usplash doesn’t show up, so there is no way to tell if that logo has been changed to something else now. The icon set looks the same and so do the pop up boxes. Its too early to have any aesthetic changes compared to the earlier version.

With this said, lets see how long I can go updating each day before something gets broken :) But so far, except for the graphics card (and thus compiz effects), everything is working quite well. If you want to try it out, its definitely not as risky as some of the earlier Alpha versions have been.

Nov 172009
 

I followed the procedure outlined by UbuntuGeek, but some of the things are little different – at least when I installed it today.

First, you’ll need to add the repository which contains the deb for Chrome.

sudo gedit /etc/apt/sources.list

Assuming you are running Karmic Koala (Ubuntu 9.10), you’ll need to add the following two lines towards the end of that file.

deb http://ppa.launchpad.net/chromium-daily/ppa/ubuntu karmic main
deb-src http://ppa.launchpad.net/chromium-daily/ppa/ubuntu karmic main

Next, you’ll have to retrieve the PGP keys for this repository.

sudo add-apt-repository ppa:chromium-daily/ppa

Update the sources,

sudo apt-get update

And then instal Chrome

sudo apt-get install chromium-browser

After the installation is successful, you can launch the browser, and import settings from Mozilla Firefox. However, Firefox needs to be closed when the importing of options and favourites is taking place. When Chrome restarts, it will have options configured like you had them in Firefox. The are no add-ons that I could find for Chrome, though – Adblock Plus and Video Download Helper are the two plugins that would make me stick with Firefox for a while.

Nov 102009
 

Sometimes when you change some of the IP settings, or are using a different wireless card on a machine that has been registered with a server, and for many other reasons, you might have encountered a warning which would’ve looked like this:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
f2:92:1d:da:81:2a:d7:16:0a:48:f0:43:20:1c:f4:b5
………………..

The simplest way to deal with this is to remove the ~/.ssh folder, however this clears out all the exchanged keys with all the ssh machines you have ever communicated with. Removing the ~/.ssh folder would mean that each time you reconnect to a SSH server that you have previously connected to, you will have to confirm that the connection is secure and all that.

There is however another simple way to change just the entry for a specific server in question. At the terminal type in -

ssh-keygen -R name_of_the_server.com

name_of_the_server.com in the above example would need to be replaced by the actual server name that you are trying to connect.

Oct 292009
 

The snapshot before the LTS version of Ubuntu is out now! Karmic Koala would be supported for about another year after which one will have to upgrade to  Lucid Lynx, which would be coming out in April 2010, this the name Ubuntu 10.04 LTS.

Karmic has been functional on my machines since Alpha 3 – so no surprises await me as of today. But I would be posting some observations and neat tricks that one can use with Karmic Koala and Ubuntu Linux in general.

The first trick is to use a torrent for downloading the .iso image instead of downloading it directly from some mirror. The advantage of doing that is that you get much faster download rates when using P2P networks for downloading the .iso image, this is especially true for a week since the release, since the mirrors literally crawl to a halt from all the traffic following the release.

Karmic Koala (Ubuntu 9.10): Header used during release

Karmic Koala (Ubuntu 9.10): Header used during release

The listing of all the torrents for Ubuntu 9.10 codenamed Karmic Koala can be found at:

Karmic Koala (Ubuntu 9.10) : List of releases on bit torrent

If you come across some performance issues, you can always take your questions to Ubuntu Forums, where you can search if someone has already resolved that issue, and if not, post a query.

Oct 262009
 

Its not quite obvious how to change the default size of gnome-terminal from the gconf-editor menu. The terminal itself is a subset of xterm. Gnome-terminal is an xterm emulator, and it follows a termcap file for this.

On gnome based distributions (Fedora/SUSE/Debian/Ubuntu etc.) do the following:

sudo gedit /usr/share/vte/termcap/xterm

There’s a lot of stuff in this file you probably don’t want to touch, but you can change the line that describes the terminal geometry:

xterm-xfree86|xterm-new|xterm terminal emulator (XFree86):\
:am:km:mi:ms:xn:\
:co#80:it#8:li#24:\

:co#80 specifies 80 columns, and li#24 specifies 24 lines. Change this to 100 and 30 or whatever you want.

:co#100:it#8:li#30:\

Now all terminals should open for this default size.

Adopted from a post on Fedora Forums.