This commit is contained in:
jupfi 2024-06-24 18:09:46 +02:00
parent c72be61c0f
commit 1fceff04d7
4 changed files with 36 additions and 17 deletions

View file

@ -233,8 +233,14 @@ class FunctionOption(Option):
obj.value = Function.from_json(data["value"]) obj.value = Function.from_json(data["value"])
return obj return obj
class TableOption(Option): class TableOption(Option):
"""A table option has rows and columns and can be used to store a table of values. The value is a list of lists.""" """A table option has rows and columns and can be used to store a table of values.
The table option acts as a 'meta' option, which means that we can add different types of options to the table as rows.
Associated with every row we can add a number of different values.
The number of rows can be adjusted at runtime.
"""
def __init__(self, name: str, value) -> None: def __init__(self, name: str, value) -> None:
"""Initializes the table option.""" """Initializes the table option."""

View file

@ -1,3 +1,5 @@
"""The phase table module contains the PhaseTable class, which interprets the TX parameters of a QuackSequence object and then generates a table of different phase values and signs for each phasecycle."""
import logging import logging
import numpy as np import numpy as np
from collections import OrderedDict from collections import OrderedDict
@ -11,6 +13,7 @@ class PhaseTable:
"""A phase table interprets the TX parameters of a QuackSequence object and then generates a table of different phase values and signs for each phasecycle.""" """A phase table interprets the TX parameters of a QuackSequence object and then generates a table of different phase values and signs for each phasecycle."""
def __init__(self, quackseq): def __init__(self, quackseq):
"""Initializes the phase table."""
self.quackseq = quackseq self.quackseq = quackseq
self.phase_array = self.generate_phase_array() self.phase_array = self.generate_phase_array()
@ -21,7 +24,6 @@ class PhaseTable:
phase_array (np.array): A table of phase values for each phasecycle. phase_array (np.array): A table of phase values for each phasecycle.
The columns are the values for the different TX pulse parameters and the rows are the different phase cycles. The columns are the values for the different TX pulse parameters and the rows are the different phase cycles.
""" """
phase_table = OrderedDict() phase_table = OrderedDict()
events = self.quackseq.events events = self.quackseq.events
@ -63,7 +65,9 @@ class PhaseTable:
logger.info(phase_table) logger.info(phase_table)
# Now get the maximum phase group # Now get the maximum phase group
max_phase_group = int(max([phase_group for phase_group, _ in phase_table.values()])) max_phase_group = int(
max([phase_group for phase_group, _ in phase_table.values()])
)
logger.info(f"Max phase group: {max_phase_group}") logger.info(f"Max phase group: {max_phase_group}")
@ -155,7 +159,9 @@ class PhaseTable:
try: try:
total_group_phases[i] += [parameter, phases[i]] total_group_phases[i] += [parameter, phases[i]]
except IndexError: except IndexError:
logger.info(f"Index Error 1: Parameter {parameter}, Phases: {phases}") logger.info(
f"Index Error 1: Parameter {parameter}, Phases: {phases}"
)
return total_group_phases return total_group_phases
@ -170,7 +176,9 @@ class PhaseTable:
try: try:
phase_array[row, column] = phase_value phase_array[row, column] = phase_value
except IndexError as e: except IndexError as e:
logger.info(f"Index error 2: {row}, {column}, {phase_value}, {phase}, {e}") logger.info(
f"Index error 2: {row}, {column}, {phase_value}, {phase}, {e}"
)
logger.info(phase_array) logger.info(phase_array)
@ -191,8 +199,10 @@ class PhaseTable:
@property @property
def n_phase_cycles(self) -> int: def n_phase_cycles(self) -> int:
"""The number of phase cycles in the sequence."""
return self.phase_array.shape[0] return self.phase_array.shape[0]
@property @property
def n_parameters(self) -> int: def n_parameters(self) -> int:
"""The number of TX pulse parameters in the sequence."""
return self.phase_array.shape[1] return self.phase_array.shape[1]

View file

@ -11,8 +11,9 @@ This also works for Samples with spin > 1.
from quackseq.pulsesequence import QuackSequence from quackseq.pulsesequence import QuackSequence
from quackseq.functions import RectFunction from quackseq.functions import RectFunction
def create_COMPFID():
def create_COMPFID():
"""Creates a composite FID sequence."""
COMPFID = QuackSequence("COMPFID") COMPFID = QuackSequence("COMPFID")
COMPFID.add_pulse_event("tx1", "3u", 100, 0, RectFunction()) COMPFID.add_pulse_event("tx1", "3u", 100, 0, RectFunction())
COMPFID.add_pulse_event("tx2", "6u", 100, 45, RectFunction()) COMPFID.add_pulse_event("tx2", "6u", 100, 45, RectFunction())

View file

@ -3,8 +3,10 @@
from quackseq.pulsesequence import QuackSequence from quackseq.pulsesequence import QuackSequence
from quackseq.functions import RectFunction from quackseq.functions import RectFunction
def create_SEPC() -> QuackSequence: def create_SEPC() -> QuackSequence:
"""Creates a simple spin echo sequence with phase cycling. """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 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 phase cycling is set to cycle through 0°, 90°, 180°, 270° for the first pulse and constant 180° for the second pulse.