# FrameDynamics
FrameDynamics is a python package that provides numerical simulations for the
field of pulse sequence development in magnetic resonance.
A coupling Hamiltonian is modulated in the toggling or interaction frame
according to the specified pulse sequence and offset frequencies.
The trajectory of the time-dependent Hamiltonian can be plotted or used
to calculate the zeroth order average Hamiltonian (higher order terms might be
available in following versions of FrameDynamics).
Theoretical background can be found in the publication (coming soon...).
## Installation
The python package can be installed via PyPI:
```
pip install FrameDynamics
```
## Simulations
Two examples shall be given: the WAHUHA sequence and a heteronuclear echo consisting of a shaped pulse and a hard 180° pulse.
More examples can be found in the FrameDynamics github-repository ([link](https://github.com/jdhaller/FrameDynamics/tree/main/examples)).
### Example #1: WAHUHA sequence
Initialize frame:
```Python
from FrameDynamics.Frame import Frame
frame = Frame(["I", "J"])
```
Specify the interaction:
```Python
interaction = frame.set_interaction("I", "J", "Dstrong")
```
Define the pulse sequence:
```Python
tau = 5 * 10**(-5)
frame.delay(tau)
frame.pulse(["I", "J"], 90, 10**(5), 0)
frame.delay(tau)
frame.pulse(["I", "J"], 90, 10**(5), 3)
frame.delay(2*tau)
frame.pulse(["I", "J"], 90, 10**(5), 1)
frame.delay(tau)
frame.pulse(["I", "J"], 90, 10**(5), 2)
frame.delay(tau)
```
Start the simulations and plot trajectories. Using multiprocessing, the scope has to be resolved in Windows.
```Python
if __name__ == "__main__":
frame.start(traject=True)
frame.plot_traject(interaction, save="WAHUHA.png")
```
## Example #2: Reburp pulse
Load Frame and Block class. Block class is used to align different blocks
in the pulse sequence (e.g. Reburp pulse and 180° hard pulse in heteronuclear
echo)
```Python
import numpy as np
from FrameDynamics.Frame import Frame
from FrameDynamics.Block import Block
frame = Frame(["I", "S"])
```
Specify the interaction:
```Python
interaction = frame.set_interaction("I", "S", "Jweak")
```
Specify offset frequencies:
```Python
off = 5000
offsetsI = np.linspace(-off, off, 61)
offsetsS = np.linspace(-off, off, 61)
frame.set_offset("I", offsetsI)
frame.set_offset("S", offsetsS)
```
Load pulse shape to array:
```Python
Reburp = frame.load_shape("Reburp.1000")
```
**After** the interaction and offsets are set for the Frame object, one can now
initialize the Block class for each block. The frame-object has to be passed to the Block() class:
```Python
block1 = Block(frame, ["I"])
block2 = Block(frame, ["S"])
```
Define a Reburp pulse on "I" and hard pulse on "S":
```Python
block1.shape(["I"], Reburp, 1000*10**(-6), 6264.8, 1)
block2.pulse(["S"], 180, 10**(5), 1)
```
Align Reburp ("I") and hard pulse ("S") and start simulation without
multiprocessing (MP=False):
```Python
frame.align(block1, block2, alignment="center")
frame.start(MP=False, traject=True)
```
Create offset-dependent 2D graph that is plotted against both offsets:
```Python
frame.plot_H0_2D(interaction)
```
Create offset-dependent 1D graph that is plotted against specified offsets ("S"):
```Python
frame.plot_H0_1D(interaction, "S", offset=0.)
```
Plot trajectories for specified interaction and operators (the given operators are default values).
```Python
frame.plot_traject(interaction, operators=["x1","y1","z1","xx","yy","zz"])
```
Raw data
{
"_id": null,
"home_page": "http://github.com/jdhaller/FrameDynamics",
"name": "FrameDynamics",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "NMR interaction average Hamiltonian theory toggling frame",
"author": "Jens Daniel Haller",
"author_email": "jhaller@gmx.de",
"download_url": "https://files.pythonhosted.org/packages/c7/95/0d06591d77fc5b6fc06fc123fa2600b1332cd7fe9e80497a88da8b1411a9/FrameDynamics-0.1.6.tar.gz",
"platform": null,
"description": "\n# FrameDynamics\n\nFrameDynamics is a python package that provides numerical simulations for the \nfield of pulse sequence development in magnetic resonance. \n\nA coupling Hamiltonian is modulated in the toggling or interaction frame \naccording to the specified pulse sequence and offset frequencies. \n\nThe trajectory of the time-dependent Hamiltonian can be plotted or used \nto calculate the zeroth order average Hamiltonian (higher order terms might be \navailable in following versions of FrameDynamics).\n\nTheoretical background can be found in the publication (coming soon...).\n\n## Installation\n\nThe python package can be installed via PyPI:\n\n```\npip install FrameDynamics\n```\n## Simulations\nTwo examples shall be given: the WAHUHA sequence and a heteronuclear echo consisting of a shaped pulse and a hard 180\u00b0 pulse. \n\nMore examples can be found in the FrameDynamics github-repository ([link](https://github.com/jdhaller/FrameDynamics/tree/main/examples)).\n\n### Example #1: WAHUHA sequence\n\nInitialize frame:\n```Python\nfrom FrameDynamics.Frame import Frame\nframe = Frame([\"I\", \"J\"]) \n```\n\nSpecify the interaction:\n```Python\ninteraction = frame.set_interaction(\"I\", \"J\", \"Dstrong\")\n```\n\nDefine the pulse sequence:\n```Python\ntau = 5 * 10**(-5)\nframe.delay(tau)\nframe.pulse([\"I\", \"J\"], 90, 10**(5), 0)\nframe.delay(tau)\nframe.pulse([\"I\", \"J\"], 90, 10**(5), 3)\nframe.delay(2*tau)\nframe.pulse([\"I\", \"J\"], 90, 10**(5), 1)\nframe.delay(tau)\nframe.pulse([\"I\", \"J\"], 90, 10**(5), 2)\nframe.delay(tau)\n``` \n\nStart the simulations and plot trajectories. Using multiprocessing, the scope has to be resolved in Windows.\n```Python\nif __name__ == \"__main__\":\n frame.start(traject=True)\n frame.plot_traject(interaction, save=\"WAHUHA.png\")\n```\n\n## Example #2: Reburp pulse\n\nLoad Frame and Block class. Block class is used to align different blocks\nin the pulse sequence (e.g. Reburp pulse and 180\u00b0 hard pulse in heteronuclear\necho)\n```Python\nimport numpy as np\nfrom FrameDynamics.Frame import Frame\nfrom FrameDynamics.Block import Block\nframe = Frame([\"I\", \"S\"])\n```\n\nSpecify the interaction:\n```Python\ninteraction = frame.set_interaction(\"I\", \"S\", \"Jweak\")\n```\n\nSpecify offset frequencies:\n```Python\noff = 5000\noffsetsI = np.linspace(-off, off, 61)\noffsetsS = np.linspace(-off, off, 61)\nframe.set_offset(\"I\", offsetsI)\nframe.set_offset(\"S\", offsetsS)\n```\nLoad pulse shape to array:\n```Python\nReburp = frame.load_shape(\"Reburp.1000\")\n```\n\n**After** the interaction and offsets are set for the Frame object, one can now\ninitialize the Block class for each block. The frame-object has to be passed to the Block() class:\n\n```Python\nblock1 = Block(frame, [\"I\"])\nblock2 = Block(frame, [\"S\"])\n```\n\nDefine a Reburp pulse on \"I\" and hard pulse on \"S\":\n```Python\nblock1.shape([\"I\"], Reburp, 1000*10**(-6), 6264.8, 1)\nblock2.pulse([\"S\"], 180, 10**(5), 1)\n```\n\nAlign Reburp (\"I\") and hard pulse (\"S\") and start simulation without \nmultiprocessing (MP=False):\n```Python\nframe.align(block1, block2, alignment=\"center\")\nframe.start(MP=False, traject=True)\n```\n\nCreate offset-dependent 2D graph that is plotted against both offsets:\n```Python\nframe.plot_H0_2D(interaction)\n```\n\nCreate offset-dependent 1D graph that is plotted against specified offsets (\"S\"):\n```Python\nframe.plot_H0_1D(interaction, \"S\", offset=0.)\n```\n\nPlot trajectories for specified interaction and operators (the given operators are default values). \n```Python\nframe.plot_traject(interaction, operators=[\"x1\",\"y1\",\"z1\",\"xx\",\"yy\",\"zz\"])\n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Simulations of the average Hamiltonian.",
"version": "0.1.6",
"split_keywords": [
"nmr",
"interaction",
"average",
"hamiltonian",
"theory",
"toggling",
"frame"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6ac2c309a2a13a0b1a8a763c20037052a54b70bb9b5753d372ecaa42d386108f",
"md5": "8c7207a20ef2058319283c4cfcc77d59",
"sha256": "af2167dae705c126a78882c2b7404c5293032cd51b39b97c74e056629c1dda80"
},
"downloads": -1,
"filename": "FrameDynamics-0.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8c7207a20ef2058319283c4cfcc77d59",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 17742,
"upload_time": "2023-01-04T09:16:23",
"upload_time_iso_8601": "2023-01-04T09:16:23.604138Z",
"url": "https://files.pythonhosted.org/packages/6a/c2/c309a2a13a0b1a8a763c20037052a54b70bb9b5753d372ecaa42d386108f/FrameDynamics-0.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c7950d06591d77fc5b6fc06fc123fa2600b1332cd7fe9e80497a88da8b1411a9",
"md5": "2b41f0a191d1ab1724487723c2817ff6",
"sha256": "e117b45958e2527aae0adbf2578eed71d699fb16d248b5143a9f7e185c3c1871"
},
"downloads": -1,
"filename": "FrameDynamics-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "2b41f0a191d1ab1724487723c2817ff6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 15340,
"upload_time": "2023-01-04T09:16:25",
"upload_time_iso_8601": "2023-01-04T09:16:25.236340Z",
"url": "https://files.pythonhosted.org/packages/c7/95/0d06591d77fc5b6fc06fc123fa2600b1332cd7fe9e80497a88da8b1411a9/FrameDynamics-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-04 09:16:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "jdhaller",
"github_project": "FrameDynamics",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "numpy",
"specs": []
},
{
"name": "scipy",
"specs": [
[
">=",
"1.8.0"
]
]
},
{
"name": "matplotlib",
"specs": []
}
],
"lcname": "framedynamics"
}