Showing posts with label pulse sequence. Show all posts
Showing posts with label pulse sequence. Show all posts

23 August 2013

499. Briefly: Drawing NMR sequences using metapost and Mark White's

Since it's Friday afternoon and I'm not likely to get anything useful done in the hour that remains before going home, I might as well put up another post.

Since posting I've had a look at this:

And that actually is (almost -- let's not get carried away here) exactly what I have been looking for. The main issue was that it's meant for metapost -- or rather, the main issue was my unfamiliarity with metapost. Anyway, my life is know complete.

So here's how to get started...

First 'install' the metapost script:
sudo apt-get install texlive-metapost
mkdir ~/texmf/metapost
cd ~/texmf/metapost -p
sudo texhash

Next, time to test-drive it
mkdir ~/tmp/pulse_test -p
cd ~/tmp/pulse_test
input beginfig(0); initf; startline(rf,"RF"); xline(1); xpulse(0.5,0.5,"90"); ospan(-0.25,-1.0,1.5,"d1"); xline(0.75); xpulse(1.0,0.5,"180"); ospan(-0.5,-1.0,1.5,"d1"); xline(1.0); ospan(0,-1.0,1.5,"vd"); xline(1.5); xacq(2); endfig;
mpost mptopdf test.0 pdftops -eps test-0.pdf test-0.eps

Now, I somehow suspect you can embed metapost scripts directly in .tex documents, but from my brief testing I haven't quite managed to make it work.

498. Briefly: Drawing NMR pulse sequences using APSEQ and Mathematica

There are two things that have been bothering me on linux -- one is the difficulty of creating annotated PDF documents, but it seems like things are slowly improving (we still don't have a really good way of creating /editable/ annotations). Another is the issue of creating NMR pulse-sequence drawings. To be fair, it doesn't seem like the situation is much better on Windows or OSX.

Anyway, I still don't have a good way of doing this, but at least I have A way of getting it done: APSEQ. The main drawback is that it requires Mathematica, which I don't like much (I get by with octave and maxima) in addition to being proprietary. But it will do for now.

NOTE: I just needed to 'Get It Done' quickly, so I didn't spend any time looking at the following potential alternatives: (metapost -- which should be tex compatible, right) (python code) (the URL is fairly descriptive)
They all seem to depend on latex in some way or another.

There's also but I haven't actually found the sources.

Anyway, here's how to get started with APSEQ:

mkdir ~/tmp/apseq -p
cd ~/tmp/apseq
tar xvf apsDistribution.tar.gz
cd zip.feb15/
Mathematica 7.0 for Linux x86 (64-bit) Copyright 1988-2009 Wolfram Research, Inc. In[1]:= << part01 loaded part02 loaded part03 loaded part04 loaded mscp loaded nmr.extra loaded loaded In[2]:= draw[pulseSeq[hahn, echo]={channels[1H],pulse[90],delay[t1],pulse[180],delay[t1],delay[t2],acquire[taq]}] Out[2]= hahn_echo.pdf In[3]:=

which gives you something like this:
Spin echo sequence
The figure is output as a pdf, but it's easy enough to open it in inkscape and converting it to an .eps file.