Archive for January, 2009

NMR language

Posted in NMR generator, NMR simulator with tags , on January 9, 2009 by kpervushin

I propose to create a better language for formal description of NMR experiments than say Bruker or Varian coding language. We will encode NMR experiments using this optimized universal syntax and store them in a web database for subsequent translation (at setup time) into Bruker coding for execution on a given real spectrometer or to Spinach for simulation. Thus, we can store only an blueprint of an experiment removing its immedeate implementational dependances. This will help to optimize individual experiments using theoretcal models.

NMR experiment consists of a basic timing of events diagram known generically as pulse sequence as such and a calibration convention connecting abstract entities as a 90deg pulse to shaped radio frequency burst of given strength (in db units) and time duration specific to a given spectrometer as well as some auxiliraly files like composite pulse decoupling sequences inserted as wholistic locked units within the basic time diagram.

A certain high level (generalized) representaion of experiments ideally should be human oriented with dynamically accessible context information (like spin state at this time or pulse). In one of my projects (submitted to Bruker, but rejected) we proposed even to generate NMR experiments directly from chemical structure, e.g. just mark spins to be correlated and get working experiment. At this time I was a member of Informatics Institute of Uni Zurich, people their liked this kind of global ideas and were ready to try to implement.

We should list requirements for such a language first, of course.

Well, after some thinking, I propose the radical solution — I will write a compiler that would take pulse sequence description and generate the effective Liouvillian stack. It seems there’s no other way than the one musicians are taking — they have a basic time grid and all events are snapped to it and discretized on it. The grid will be adaptive and will have a form of a vector of timings plus a stack of matrices. Run that through expv and we’re done.

server side Spinach

Posted in NMR generator, NMR simulator on January 6, 2009 by kpervushin

Dear Ilya,

nice minutes! Impressed. What kind of software did you use to produce them? ms project?

As to XML description of pulse sequences. An experiment contains the timeing events digaram (akin you gif picture) and auxiliray info like calibration tables and cpd, shapes etc files. The problem is that we need first to calculate a given experiment encoded in say Bruker or Varian library in Spinach in order to make meaningful interpretaion of events in timing diagram such as hard pulses to 90 degree, 180 degree or other categories. Only after that graphical rendering makes any sence. More over, such a graphical picture is intuitively clear only for simpliest HSQC or COSY like experiments. However, if you look at 3D experiments, the jumble of pulses and delays quickly makes traditional graphical representation completely usless. My point is that the experiment not nessessery shall be represented as actual timing events diagram, but we can move to more general logical LEGO blocks like transfer between this and that spin state. This would reveal the design behind the experiment, and in fact, would enable optimal construction of new experiments from the designed goals, like to correlate this spin state with this using LEGO styled blockes like INEPT. Very soon we have to move to optimization of the existing pulse sequences, so that all controls (phases, delays etc) should be accessible programmatically. What you are showing as XML stab, can be in fact a representational derivative of a higher order structure, but not the basis of experiment programming.

I have created a database of commonly used experiments encapsulating all files and procedures needed to setup an experiment of choice on any given spectrometer. I used CARA as an environment (www.nmr.ch) and LUA language (with lots of widget classes from CARA) to create GUI. I meant it to be lightweight, so that the whole database is a single XML file shareble via web. Soon I bumped into a problem of many concurrent users modifying entires in the database creating parallel versions of this file. We decided to move to server-side solution to maintain order in multiuser env and harniss the power of community to quickly debug the entire pool of experiments. My postdoc in Basel took one of the free wikis (written in .NET on C#) and started to hack server-side solution while I am doing desktop application. From here stemms my suggestion to use C#, – I have there experience and manpower already.

Ideally, all of us wish to have a united site with social networking possibilities, where we can expose community editable NMR experiments of any complexity with all aux files in a form which can self setup on any end user spectrometer (inspecting the local configuration if needed). Of course, Spinach fits neatly into this scheme providing a powerful analytical tool capable of semantic analysis and optimality checks (against fundamental quatum bounds) of the submissions followed in perspective by actual optimization.

I strongly recommend not to write GUI from scratch and even not to use David’s hacks. They might seem useful, but in fact, they will exist only in matlab environment as prototypes. Still better is to adopt an existing open source server side solution (wiki like, or more global content management systems, there are aplenty of them) equipped with CSS, styling etc and build GUI on the top of it right from the beggining.

As to David’s simulator. David sent me a trial version, but it was very unstable. From conversations with him it seems that he is very open to collaborations. However, I am not sure you would enjoy finding youself reverse engineering his code to furnish a prototype, just to discover that web application needs a entirely different set of widgets and programming techniques.

Konstantin

simulation of decoupling

Posted in NMR generator, NMR simulator with tags , , , on January 4, 2009 by kpervushin

I can write a function that would project all interactions of a specified type out of the Liouvillian and put them back when necessary. Something like

[L,C]=decouple(L,spin1,spin2);

… running with ‘decoupled’ L

L=recouple(L,C);

Would that be good enough?

Dear Illya,

a nice suggestion, but does not seem like a solution. The actual decoupling is performed with a sequence of (phase, amplitude modulated) finite pulses run in parallel with all other events on the other remaining channels. Of course, proper simulation of the effect of such a perturbation would require numeric propagation of the density operator through such a complex sequence. If decoupling sequence is suboptimal , it might inflict severe losses of sensitivity. Therefore, adequate simulation of decoupling is an important issue. In fact, in solid state NMR decoupling is an essence of everything with just a slightest misset of power resulting in no signal at all.

I do not see any simple solution at the moment, since this problem belongs to “musician book” (parallel events) category. At some point we have to make an object oriented formal representation of NMR experiment taking care of such an intrinsic parallelism. What bothers me now really is that in the manuscript we have to indicate that composite decoupling is not implemented or implemented as just continuous irradiation droping modulation part whatsoever. This is not devastating but not nice either.

Generally, we do not have an effective (and universal) language describing multi channel sequence of parallel events. I am sure you have seen my inputs to Spinach, they do not look even 1/2 way attractive or elegant to an external user.

Dear Konstantin,

I am in the process thinking about the human-readable input style for Spinach (something along the lines of Gaussian or GAMESS inputs, a stub enclosed – your comments would be appreciated), for both the spin system and the experiment to be run. Gareth Charnock in my group is developing a user-friendly GUI for Spinach (currently a GaussView-style point-and-click spin system specification aid).

We’ll have to think long and hard about pulse sequence specification language. It looks like the most straightforward way would be to implement a “compiler” — a function that would read the user sequence input and generate a stack of Liouvillians through which the spin system has to be propagated (the time grid would probably need to be non-uniform). The propagation as such then would be a straightforward loop.

I’ll look at the way Bruker, Varian, Simpson, Spinevolution etc implement their sequence language and try putting together something neat and flexible. Meanwhile, having a neat spin system specification would be a start – please take a look at the enclosed file. I will write a read_ss.m function that would read it.

While that’s in progress, the “algebraic” decoupling described below should serve as a crutch.

Best wishes,

Ilya.

Dear Ilya,

> I’ll look at the way Bruker, Varian, Simpson, Spinevolution etc implement their sequence language and try putting together something neat and flexible. Meanwhile, having a neat spin system specification would be a start – please take a look at the enclosed file. I will write a read_ss.m function that would read it.

The tagged XML-like description appears to be the natural representation of spin system data. I’d suggest to render it is a class with formal properties, states and associated methods built in this class. This will be totally in style with object oriented programming, reusable and flexible. The actual rendering (point-and-click or anything else) can vary, depending on the platform. This brings the question of the general use of the system.

Strategically I suggest:

1. To make Spinach a server side application.

2. To use ASP.NET with C# as implementation tools. This requires porting Spinach algebraic core to C#, which should be not that difficult to achieve.

Advantages: 1) drastically lowering barrier of the use of the simulator since no local installations are needed just web access. 2) we can use powerful GUI of the web browser to setup analysis and representation of experiments. 3) We can use .NET infrastructure for object oriented programming, access to databases, commonly accepted server side GUI. 4) We add a crucial enhancement to the system in the form of social networked community of users. We can have a public database of experiments, results, documentation, a wiki as well as private sub-collections in development which can be easily exchanged.

NMR generator on ASP.NET

Posted in NMR generator on January 1, 2009 by kpervushin

Google SVN wiki link

http://code.google.com/p/nmrgenerator/wiki/NewSetup?ts=1229446245&updated=NewSetup

Introduction

All the tools are free of charge.

What you will need

  1. .NET Framework 3.5 SP1 and ASP.NET 2.0 (http://msdn.microsoft.com/en-us/netframework/aa569263.aspx)
  2. Visual Web Developer 2008 Express Edition (http://www.microsoft.com/express/vwd/)
  3. TortoiseSVN (http://tortoisesvn.tigris.org/)
  4. MySQL (http://www.mysql.com/) or MSSQL 2008 Express (http://www.microsoft.com/express/sql/default.aspx) – second will be used at the end
  5. MySql Gui Tools (http://dev.mysql.com/downloads/gui-tools/5.0.html)
  6. MySQL ODBC connector (http://dev.mysql.com/downloads/connector/odbc/5.1.html)
  7. MySQL .NET Connector (http://dev.mysql.com/downloads/connector/net/5.2.html)
  8. ILMerge (http://www.microsoft.com/downloads/details.aspx?familyid=22914587-b4ad-4eae-87cf-b14ae6a939b0&displaylang=en)
  9. Straight hands

What you will do

  1. Install .NET framework. ASP.NET will be installed together with it
  2. Install Visual Web Developer 2008
  3. Install TortoiseSVN. This will add additional content to the right click menu.
  4. Find the default folder for your VWD projects. Default is \Documents\Visual Studio 2008\Projects. Right click the folder and do SVN Checkout. In the new window: URL of repository – https://nmrgenerator.googlecode.com/svn/trunk/ nmrgenerator; Checkout Depth – Fully recursive; revision – HEAD revision. When you click ok, you will be asked for credentials to access the repository. Use you gmail account username (the gmail email) you password you will find on this page (http://code.google.com/hosting/settings).
  5. Install MySql, when asked specify root password
  6. Install MySQL GUI Tools
  7. Install All MySQL Connectors
  8. Run ODBC Data Source Administrator – there setup two new DSNs. 1 – Data Source Name = “NMR Experiments”, Server = “localhost”; Port=”3306″ (or the one u set when installed MySQL); user = “nmr”; password = “v rot mne nogi”; Database =”nmrexperiments”. 2 – Data Source Name = “NMR UserData”; Database = “nmruserdata” , the rest is the same.
  9. In the NMR generator project folder locate the folder MySQLDatabase. It contains a backup of DB.
  10. Run “MySQL Administrator” (component of mysql gui tools) with root credentials. In restore tab initiate db restore, when asked select the file from previously located folder. After process is finished the must be three new databases shown in Catalogs tab. In users tab create new user: name – nmr, password – “v rot mne nogi”. Specify SELECT and INSERT permisions for nmrexperiments database and SELECT,INSERT, DELETE, REPLACE and UPDATE for nmruserdata database.
  11. Install ILMerge into default directory
  12. If things work, don’t touch anything, otherwise write here.
Follow

Get every new post delivered to your Inbox.