From c72be61c0f0efad40c180e39ef6474424dcda120 Mon Sep 17 00:00:00 2001 From: jupfi Date: Tue, 18 Jun 2024 16:19:50 +0200 Subject: [PATCH] Moved example sequences to base repo. --- src/quackseq/sequences/COMPFID.py | 30 +++++++++++++++++++++++++++++ src/quackseq/sequences/FID.py | 18 +++++++++++++++++ src/quackseq/sequences/SE.py | 19 ++++++++++++++++++ src/quackseq/sequences/SEPC.py | 32 +++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 src/quackseq/sequences/COMPFID.py create mode 100644 src/quackseq/sequences/FID.py create mode 100644 src/quackseq/sequences/SE.py create mode 100644 src/quackseq/sequences/SEPC.py diff --git a/src/quackseq/sequences/COMPFID.py b/src/quackseq/sequences/COMPFID.py new file mode 100644 index 0000000..942d2a1 --- /dev/null +++ b/src/quackseq/sequences/COMPFID.py @@ -0,0 +1,30 @@ +"""Composite FID example. + +This example demonstrates how to simulate a composite FID signal using the quackseq simulator. + +See the paper: +Sauer, K.L., Klug, C.A., Miller, J.B. et al. Using quaternions to design composite pulses for spin-1 NQR. Appl. Magn. Reson. 25, 485–500 (2004). https://doi.org/10.1007/BF03166543 + +This also works for Samples with spin > 1. +""" + +from quackseq.pulsesequence import QuackSequence +from quackseq.functions import RectFunction + +def create_COMPFID(): + + COMPFID = QuackSequence("COMPFID") + COMPFID.add_pulse_event("tx1", "3u", 100, 0, RectFunction()) + COMPFID.add_pulse_event("tx2", "6u", 100, 45, RectFunction()) + # This makes the phase 45, 135, 225, 315 (because of the previous 45 degree phase shift and 360/4 = 90 degree phase shift) + COMPFID.set_tx_n_phase_cycles("tx2", 4) + COMPFID.add_blank_event("blank", "5u") + + COMPFID.add_readout_event("rx", "100u") + + # No phase shifiting of the receive data but weighting of -1 for the 45 degree pulse, +1 for the 135 degree pulse, -1 for the 225 degree pulse and +1 for the 315 degree pulse + readout_scheme = [[1, 0], [-1, 0], [1, 0], [-1, 0]] + + COMPFID.set_rx_readout_scheme("rx", readout_scheme) + + return COMPFID \ No newline at end of file diff --git a/src/quackseq/sequences/FID.py b/src/quackseq/sequences/FID.py new file mode 100644 index 0000000..af501b1 --- /dev/null +++ b/src/quackseq/sequences/FID.py @@ -0,0 +1,18 @@ +"""Simple FID sequence with a single excitation pulse and readout event.""" + +from quackseq.pulsesequence import QuackSequence +from quackseq.functions import RectFunction + +def create_FID() -> QuackSequence: + """Creates a simple FID sequence with a single excitation pulse and readout event. + + Returns: + QuackSequence: The FID sequence + """ + FID = QuackSequence("FID") + FID.add_pulse_event("tx", "3u", 100, 0, RectFunction()) + FID.add_blank_event("blank", "5u") + FID.add_readout_event("rx", "100u") + FID.add_blank_event("TR", "1m") + + return FID \ No newline at end of file diff --git a/src/quackseq/sequences/SE.py b/src/quackseq/sequences/SE.py new file mode 100644 index 0000000..917f16a --- /dev/null +++ b/src/quackseq/sequences/SE.py @@ -0,0 +1,19 @@ +"""A simple SE sequence with a pi/2 pulse, a pi pulse, and a readout event.""" + +from quackseq.pulsesequence import QuackSequence +from quackseq.functions import RectFunction + +def create_SE() -> QuackSequence: + """Creates a simple SE sequence with a pi/2 pulse, a pi pulse, and a readout event. + + Returns: + QuackSequence: The SE sequence + """ + SE = QuackSequence("SE") + SE.add_pulse_event("pi-half", "3u", 100, 0, RectFunction()) + SE.add_blank_event("te-half", "150u") + SE.add_pulse_event("pi", "6u", 100, 0, RectFunction()) + SE.add_blank_event("blank", "50u") + SE.add_readout_event("rx", "200u") + + return SE \ No newline at end of file diff --git a/src/quackseq/sequences/SEPC.py b/src/quackseq/sequences/SEPC.py new file mode 100644 index 0000000..7c4bef5 --- /dev/null +++ b/src/quackseq/sequences/SEPC.py @@ -0,0 +1,32 @@ +"""A spin echo sequence with phase cycling.""" + +from quackseq.pulsesequence import QuackSequence +from quackseq.functions import RectFunction + +def create_SEPC() -> QuackSequence: + """Creates a simple spin echo sequence with phase cycling. + The sequence consists of a pi/2 pulse, a pi pulse, and a readout event. + + The phase cycling is set to cycle through 0°, 90°, 180°, 270° for the first pulse and constant 180° for the second pulse. + The readout phase for the different phase cycles is set to 0°, 90°, 180°, 270°. + + Returns: + QuackSequence: The SEPC sequence + """ + sepc = QuackSequence("SEPC") + sepc.add_pulse_event("pi-half", "3u", 100, 0, RectFunction()) + # This causes the phase to cycle through 0, 90, 180, 270 + sepc.set_tx_n_phase_cycles("pi-half", 4) + + sepc.add_blank_event("te-half", "150u") + # For the second pulse we just need a phase of 180 + sepc.add_pulse_event("pi", "6u", 100, 180, RectFunction()) + sepc.add_blank_event("blank", "50u") + + sepc.add_readout_event("rx", "200u") + # Readout scheme for phase cycling TX pulses have the scheme 0 90 180 270 for the first pulse and 180 always for the second pulse + readout_scheme = [[1, 0], [1, 90], [1, 180], [1, 270]] + + sepc.set_rx_readout_scheme("rx", readout_scheme) + + return sepc \ No newline at end of file