#!/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
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);
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.
Seems like the site is pretty up to date too.
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.
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
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,closemeans menu on the left, min max close on the right.
This workaround was found at: http://www.ivankamajic.com/?p=281#comment-30647
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.
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.
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.
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.
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.
The GDM in Ubuntu changed a bit since Karmic. Now you no longer need to type in both username and password. Instead there is a list of users that shows up, similar to what we have in Windows and Mac. That way you don’t accidentally type in the password when you are supposed to be typing your user name. While this is a really nice way to login, Ubuntu added a drum sound which plays each time you arrive at the login screen – this can be when a user logs out or starts the computer. There is no simple way to disable that sound using GUI. There is however a simple command line which disables this login screen sound as lets you login silently.
If you are a sudoer, open up the terminal and type in:
sudo -u gdm gconftool-2 –set /desktop/gnome/sound/event_sounds –type bool false
The next time you logout, or restart the computer, the sound won’t be played again.
****
Update: The above methods doesn’t work for everyone. There have been a couple of other methods that have been known to work.
To actually disable the “login ready” sound you need to edit your /etc/gdm/custom.conf file.
sudo gedit /etc/gdm/custom.conf
Under the [greeter] section add the line:
SoundOnLogin=false
Another method that has worked for some is the removal of ubuntu-sounds package. This will remove all the event sounds as well, but your media should work just fine.
sudo apt-get remove ubuntu-sounds
These are some of the methods that have worked for several people. YMMV – unfortunately.
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.
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.
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.
Getting the changes in .bashrc to take effect immediately, all you need to do is execute either of these following commands in the terminal -
source ~/.bashrc
or
bash
That’s it. The changes made to .bashrc file will take effect.
Had these listed on geocities, but soon geocities will be closing down, so had to rescue those puns:
- A good pun is its own reword.
- To err is human, to moo bovine.
- Energizer Bunny arrested, charged with battery.
- A man’s home is his castle, in a manor of speaking.
- A pessimist’s blood type is always b-negative
- My wife really likes to make pottery, but to me it’s just kiln time.
- Dijon vu — the same mustard as before.
- Practice safe eating – always use condiments.
- A Freudian slip is when you say one thing but mean your mother.
- If electricity comes from electrons… does that mean morality comes from morons?
- A man’s home is his castle, in a manor of speaking.
- I fired my masseuse today. She just rubbed me the wrong way.
- Dancing cheek-to-cheek is really a form of floor play.
- Reading whilst sunbathing makes you well-red.
- A hangover is the wrath of grapes.
- Corduroy pillows are making headlines.
- Is a big book on voyeurism a peeping tome?
- Sea captains don’t like crew cuts.
- Does the name Pavlov ring a bell?
- A successful diet is the triumph of mind over platter.
- Two banks with different rates have a conflict of interest.
- Time flies like an arrow. Fruit flies like a banana.
- A gossip is someone with a great sense of rumor.
- Without geometry, life is pointless.
- When you dream in color, it’s a pigment of your imagination.
- When two egotists meet, it’s an I for an I.
- Energizer Bunny arrested, charged with battery.
- Shotgun wedding: A case of wife or death.
- I used to work in a blanket factory, but it folded.
- Marriage is the mourning after the knot before.
- A successful diet is the triumph of mind over platter.
- Without geometry, life is pointless.
- Show me a piano falling down a mine shaft, and I’ll show you a flat minor.
- When a clock is hungry, it goes back four seconds.
- The man who fell into an upholstery machine is fully recovered.
- A grenade thrown into a kitchen in France would give you Linoleum Blownapart.
- The short fortuneteller who escaped from prison was a small medium at large.
- The radio station that played particularly good music was a rare medium, well-done.
- When the actress saw her first strands of gray hair, she thought she’d dye.
- Bakers trade bread recipes on a knead-to-know basis.
- Santa’s helpers are subordinate clauses.
- A good acupuncture is a jab well done.
- They also surf who only stand on waves.
- Addicted to brake fluid? Nah, I can stop any time. (Mark Foerster)
- If puns are outlawed, only outlaws will have puns.
- Bough, cough, dough, rough, sought, through, hiccough – argh!
- Man was predestined to have free will.
- She’s in love with her psychiatrist: she’s shrink-rapt
- Threw jelly at cop; conviction: carrying congealed weapon
- Cross a cannon with a bell: boomerang!
- With fronds like these, who needs anemones?
- Those who jump off a bridge in Paris are inseine.
- Australian beer is made out of kangaroo hops
- Does “Quasimodo” ring a bell? I had a hunch it would…
- Don’t use a big word where a diminutive one will suffice
- Dyslexics of the world, untie!!
- Erik the Red was a Norse of a different colour
- Help stamp out, eliminate and abolish redundancy
- In plumbing,a straight flush is better than a full house
- It looks like an optical illusion, but it isn’t
- Me…a skeptic? I trust you have proof
- Pornography? We don’t even have a pornograph!
- Puns are bad..but Poetry is……verse
- Red ship crashes into blue ship – sailors marooned.
- The beauty of a pun is in the argh of the beholder
- The cost of feathers has risen, now even down is up
- The cow ate bluegrass and mooed indigo.
- To learn about paranoids, follow them around.
- Gentlemen prefer bonds. (Andrew Mellon)
- Tried to play my shoehorn – all I got was footnotes
- Try Milk of Amnesia – when you need to forget
- When you’ve seen one shopping centre, you’ve seen a mall
- Witches fly on brooms because nature abhors a vacuum
- I put a dollar in a change machine. Nothing changed. (G. Carlin)
- A backward poet writes inverse.
- A bicycle can’t stand alone because it is two-tired.
- A boiled egg in the morning is hard to beat.
- A chicken crossing the road is poultry in motion.
- A lot of money is tainted. ‘Taint yours and ‘taint mine.
- A plateau is a high form of flattery.
- A will is a dead giveaway.
- Every calendar’s days are numbered.
- He had a photographic memory which was never developed.
- He often broke into song because he couldn’t find the key.
- If you don’t pay your exorcist you get repossessed.
- In democracy it’s your vote that counts; in feudalism it’s your count that votes.
- Marathon runners with bad footwear suffer the agony of defeat.
- She had a boyfriend with a wooden leg, but broke it off.
- The short fortuneteller who escaped from prison was a small medium at large.
- Those who get too big for their britches will be exposed in the end.
- With her marriage she got a new name and a dress.
- You feel stuck with your debt if you can’t budge it.
When you are mostly involved with coding, and use the Terminal for a fair amount of time, it’s quite beneficial if we use another Terminal window/tab for IMs. Searching around for a command line instant messenger, I learnt that there was a variant of Pidgin called Finch. It lets you connect and chat with your online buddies using nothing but text.
To install finch on Ubuntu, run:
sudo apt-get install finch
at the Terminal.
Once Finch is installed, you can load it by typing, finch at the Terminal.


Finch Chat Window
Different commands to access and configure finch can be found at:



