text:
"""
Class for reading output files from NEST simulations
( http://www.nest-simulator.org/ ).
Tested with NEST2.10.0

Depends on: numpy, quantities

Supported: Read

Authors: Julia Sprenger, Maximilian Schmidt, Johanna Senk

"""

# needed for Python3 compatibility

import os.path
import warnings
from datetime import datetime
import numpy as np
import quantities as pq

from neo.io.baseio import BaseIO
from neo.core import Block, Segment, SpikeTrain, AnalogSignal

value_type_dict = {'V': pq.mV,
                   'I': pq.pA,
                   'g': pq.CompoundUnit("10^-9*S"),
                   'no type': pq.dimensionless}

class NestIO(BaseIO):
    """
    Class for reading NEST output files. GDF files for the spike data and DAT
    files for analog signals are possible.

    Usage:
        >>> from neo.io.nestio import NestIO

        >>> files = ['membrane_voltages-1261-0.dat',
                 'spikes-1258-0.gdf']
        >>> r = NestIO(filenames=files)
        >>> seg = r.read_segment(gid_list=[], t_start=400 * pq.ms,
                             t_stop=600 * pq.ms,
                             id_column_gdf=0, time_column_gdf=1,
                             id_column_dat=0, time_column_dat=1,
                             value_columns_dat=2)
    """

    is_readable = True  # class supports reading, but not writing
    is_writable = False

    supported_objects = [SpikeTrain, AnalogSignal, Segment, Block]
    readable_objects = [SpikeTrain, AnalogSignal, Segment, Block]

    has_header = False
    is_streameable = False

    write_params = None  # writing is not supported

    name = 'nest'
    extensions = ['gdf', 'dat']
    mode = 'file'

    def __init__(self, filenames=None):
        """
        Parameters
        ----------
            filenames: string or list of strings, default=None
                The filename or list of filenames to load.
        """

        if isinstance(filenames, str):
            filenames = [filenames]

        self.filenames = filenames
        self.avail_formats = {}
        self.avail_IOs = {}

        for filename in filenames:
            path, ext = os.path.splitext(filename)
            ext = ext.strip('.')
            if ext in self.extensions:
                if ext in self.avail_IOs:
                    raise ValueError('Received multiple files with "%s" '
                                     'extention. Can only load single file of '
                                     'this type.' % ext)
                self.avail_IOs[ext] = ColumnIO(filename)
            self.avail_formats[ext] = path

    def __read_analogsignals(self, gid_list, time_unit, t_start=None,
                             t_stop=None, sampling_period=None,
                             id_column=0, time_column=1,
                             value_columns=2, value_types=None,
                             value_units=None):
        """
        Internal function called by read_analogsignal() and read_segment().
        """

        if 'dat' not in self.avail_formats:
            raise ValueError('Can not load analogsignals. No DAT file '
                             'provided.')

        # checking gid input parameters
        gid_list, id_column = self._check_input_gids(gid_list, id_column)
        # checking time input parameters
        t_start, t_stop = self._check_input_times(t_start, t_stop,
                                                  mandatory=False)

        # checking value input parameters
        (value_columns, value_types, value_units) = \
            self._check_input_values_parameters(value_columns, value_types,
                                                value_units)

        # defining standard column order for internal usage
        # [id_column, time_column, value_column1, value_column2, ...]
        column_ids = [id_column, time_column] + value_columns
        for i, cid in enumerate(column_ids):
            if cid is None:
                column_ids[i] = -1

        # assert that no single column is assigned twice
        column_list = [id_column, time_column] + value_columns
        column_list_no_None = [c for c in column_list if c is not None]
        if len(np.unique(column_list_no_None)) < len(column_list_no_None):
            raise ValueError(
                'One or more columns have been specified to contain '
                'the same data. Columns were specified to %s.'
                '' % column_list_no_None)

        # extracting condition and sorting parameters for raw data loading
        (condition, condition_column,
         sorting_column) = self._get_conditions_and_sorting(id_column,
                                                            time_column,
                                                            gid_list,
                                                            t_start,
                                                            t_stop)
        # loading raw data columns
        data = self.avail_IOs['dat'].get_columns(
            column_ids=column_ids,
            condition=condition,
            condition_column=condition_column,
            sorting_columns=sorting_column)

        sampling_period = self._check_input_sampling_period(sampling_period,
                                                            time_column,
                                                            time_unit,
                                                            data)
        analogsignal_list = []

        # extracting complete gid list for anasig generation
        if (gid_list == []) and id_column is not None:
            gid_list = np.unique(data[:, id_column])

        # generate analogsignals for each neuron ID
        for i in gid_list:
            selected_ids = self._get_selected_ids(
                i, id_column, time_column, t_start, t_stop, time_unit,
                data)

            # extract starting time of analogsignal
            if (time_column is not None) and data.size:
                anasig_start_time = data[selected_ids[0], 1] * time_unit
            else:
                # set t_start equal to sampling_period because NEST starts
                #  recording only after 1 sampling_period
                anasig_start_time = 1. * sampling_period

            # create one analogsignal per value column requested
            for v_id, value_column in enumerate(value_columns):
                signal = data[
                    selected_ids[0]:selected_ids[1], value_column]

                # create AnalogSignal objects and annotate them with
                #  the neuron ID
                analogsignal_list.append(AnalogSignal(
                    signal * value_units[v_id],
                    sampling_period=sampling_period,
                    t_start=anasig_start_time,
                    id=i,
                    type=value_types[v_id]))
                # check for correct length of analogsignal
                assert (analogsignal_list[-1].t_stop
                        == anasig_start_time + len(signal) * sampling_period)
        return analogsignal_list

    def __read_spiketrains(self, gdf_id_list, time_unit,
                           t_start, t_stop, id_column,
                           time_column, **args):
        """
        Internal function for reading multiple spiketrains at once.
        This function is called by read_spiketrain() and read_segment().
        """

        if 'gdf' not in self.avail_IOs:
            raise ValueError('Can not load spiketrains. No GDF file provided.')

        # assert that the file contains spike times
        if time_column is None:
            raise ValueError('Time column is None. No spike times to '
                             'be read in.')

        gdf_id_list, id_column = self._check_input_gids(gdf_id_list, id_column)

        t_start, t_stop = self._check_input_times(t_start, t_stop,
                                                  mandatory=True)

        # assert that no single column is assigned twice
        if id_column == time_column:
            raise ValueError('One or more columns have been specified to '
                             'contain the same data.')

        # defining standard column order for internal usage
        # [id_column, time_column, value_column1, value_column2, ...]
        column_ids = [id_column, time_column]
        for i, cid in enumerate(column_ids):
            if cid is None:
                column_ids[i] = -1

        (condition, condition_column, sorting_column) = \
            self._get_conditions_and_sorting(id_column, time_column,
                                             gdf_id_list, t_start, t_stop)

        data = self.avail_IOs['gdf'].get_columns(
            column_ids=column_ids,
            condition=condition,
            condition_column=condition_column,
            sorting_columns=sorting_column)

        # create a list of SpikeTrains for all neuron IDs in gdf_id_list
        # assign spike times to neuron IDs if id_column is given
        if id_column is not None:
            if (gdf_id_list == []) and id_column is not None:
                gdf_id_list = np.unique(data[:, id_column])

            spiketrain_list = []
            for nid in gdf_id_list:
                selected_ids = self._get_selected_ids(nid, id_column,
                                                      time_column, t_start,
                                                      t_stop, time_unit, data)
                times = data[selected_ids[0]:selected_ids[1], time_column]
                spiketrain_list.append(SpikeTrain(

                    times, units=time_unit,
                    t_start=t_start, t_stop=t_stop,
                    id=nid, **args))

        # if id_column is not given, all spike times are collected in one
        #  spike train with id=None
        else:
            train = data[:, time_column]
            spiketrain_list = [SpikeTrain(train, units=time_unit,
                                          t_start=t_start, t_stop=t_stop,
                                          id=None, **args)]
        return spiketrain_list

    def _check_input_times(self, t_start, t_stop, mandatory=True):
        """
        Checks input times for existence and setting default values if
        necessary.

        t_start: pq.quantity.Quantity, start time of the time range to load.
        t_stop: pq.quantity.Quantity, stop time of the time range to load.
        mandatory: bool, if True times can not be None and an error will be
                raised. if False, time values of None will be replaced by
                -infinity or infinity, respectively. default: True.
        """
        if t_stop is None:
            if mandatory:
                raise ValueError('No t_start specified.')
            else:
                t_stop = np.inf * pq.s
        if t_start is None:
            if mandatory:
                raise ValueError('No t_stop specified.')
            else:
                t_start = -np.inf * pq.s

        for time in (t_start, t_stop):
            if not isinstance(time, pq.quantity.Quantity):
                raise TypeError('Time value (%s) is not a quantity.' % time)
        return t_start, t_stop

    def _check_input_values_parameters(self, value_columns, value_types,
                                       value_units):
        """
        Checks value parameters for consistency.

        value_columns: int, column id containing the value to load.
        value_types: list of strings, type of values.
        value_units: list of units of the value columns.

        Returns
        adjusted list of [value_columns, value_types, value_units]
        """
        if value_columns is None:
            raise ValueError('No value column provided.')
        if isinstance(value_columns, int):
            value_columns = [value_columns]
        if value_types is None:
            value_types = ['no type'] * len(value_columns)
        elif isinstance(value_types, str):
            value_types = [value_types]

        # translating value types into units as far as possible
        if value_units is None:
            short_value_types = [vtype.split('_')[0] for vtype in value_types]
            if not all([svt in value_type_dict for svt in short_value_types]):
                raise ValueError('Can not interpret value types '
                                 '"%s"' % value_types)
            value_units = [value_type_dict[svt] for svt in short_value_types]

        # checking for same number of value types, units and columns
        if not (len(value_types) == len(value_units) == len(value_columns)):
            raise ValueError('Length of value types, units and columns does '
                             'not match (%i,%i,%i)' % (len(value_types),
                                                       len(value_units),
                                                       len(value_columns)))
        if not all([isinstance(vunit, pq.UnitQuantity) for vunit in
                    value_units]):
            raise ValueError('No value unit or standard value type specified.')

        return value_columns, value_types, value_units

    def _check_input_gids(self, gid_list, id_column):
        """
        Checks gid values and column for consistency.

        gid_list: list of int or None, gid to load.
        id_column: int, id of the column containing the gids.

        Returns
        adjusted list of [gid_list, id_column].
        """
        if gid_list is None:
            gid_list = [gid_list]

        if None in gid_list and id_column is not None:
            raise ValueError('No neuron IDs specified but file contains '
                             'neuron IDs in column %s. Specify empty list to '
                             'retrieve spiketrains of all neurons.'
                             '' % str(id_column))

        if gid_list != [None] and id_column is None:
            raise ValueError('Specified neuron IDs to be %s, but no ID column '
                             'specified.' % gid_list)
        return gid_list, id_column

    def _check_input_sampling_period(self, sampling_period, time_column,
                                     time_unit, data):
        """
        Checks sampling period, times and time unit for consistency.

        sampling_period: pq.quantity.Quantity, sampling period of data to load.
        time_column: int, column id of times in data to load.
        time_unit: pq.quantity.Quantity, unit of time used in the data to load.
        data: numpy array, the data to be loaded / interpreted.

        Returns
        pq.quantities.Quantity object, the updated sampling period.
        """
        if sampling_period is None:
            if time_column is not None:
                data_sampling = np.unique(
                    np.diff(sorted(np.unique(data[:, 1]))))
                if len(data_sampling) > 1:
                    raise ValueError('Different sampling distances found in '
                                     'data set (%s)' % data_sampling)
                else:
                    dt = data_sampling[0]
            else:
                raise ValueError('Can not estimate sampling rate without time '
                                 'column id provided.')
            sampling_period = pq.CompoundUnit(str(dt) + '*'
                                              + time_unit.units.u_symbol)
        elif not isinstance(sampling_period, pq.UnitQuantity):
            raise ValueError("sampling_period is not specified as a unit.")
        return sampling_period

    def _get_conditions_and_sorting(self, id_column, time_column, gid_list,
                                    t_start, t_stop):
        """
        Calculates the condition, condition_column and sorting_column based on
        other parameters supplied for loading the data.

        id_column: int, id of the column containing gids.
        time_column: int, id of the column containing times.
        gid_list: list of int, gid to be loaded.
        t_start: pq.quantity.Quantity, start of the time range to be loaded.
        t_stop: pq.quantity.Quantity, stop of the time range to be loaded.

        Returns
        updated [condition, condition_column, sorting_column].
        """
        condition, condition_column = None, None
        sorting_column = []
        curr_id = 0
        if ((gid_list != [None]) and (gid_list is not None)):
            if gid_list != []:
                def condition(x):
                    return x in gid_list

                condition_column = id_column
            sorting_column.append(curr_id)  # Sorting according to gids first
            curr_id += 1
        if time_column is not None:
            sorting_column.append(curr_id)  # Sorting according to time
            curr_id += 1
        elif t_start != -np.inf and t_stop != np.inf:
            warnings.warn('Ignoring t_start and t_stop parameters, because no '
                          'time column id is provided.')
        if sorting_column == []:
            sorting_column = None
        else:
            sorting_column = sorting_column[::-1]
        return condition, condition_column, sorting_column

    def _get_selected_ids(self, gid, id_column, time_column, t_start, t_stop,
                          time_unit, data):
        """
        Calculates the data range to load depending on the selected gid
        and the provided time range (t_start, t_stop)

        gid: int, gid to be loaded.
        id_column: int, id of the column containing gids.
        time_column: int, id of the column containing times.
        t_start: pq.quantity.Quantity, start of the time range to load.
        t_stop: pq.quantity.Quantity, stop of the time range to load.
        time_unit: pq.quantity.Quantity, time unit of the data to load.
        data: numpy array, data to load.

        Returns
        list of selected gids
        """
        gid_ids = np.array([0, data.shape[0]])
        if id_column is not None:
            gid_ids = np.array([np.searchsorted(data[:, 0], gid, side='left'),
                                np.searchsorted(data[:, 0], gid, side='right')])
        gid_data = data[gid_ids[0]:gid_ids[1], :]

        # select only requested time range
        id_shifts = np.array([0, 0])
        if time_column is not None:
            id_shifts[0] = np.searchsorted(gid_data[:, 1],
                                           t_start.rescale(
                                               time_unit).magnitude,
                                           side='left')
            id_shifts[1] = (np.searchsorted(gid_data[:, 1],
                                            t_stop.rescale(
                                                time_unit).magnitude,
                                            side='left') - gid_data.shape[0])

        selected_ids = gid_ids + id_shifts
        return selected_ids

    def read_block(self, gid_list=None, time_unit=pq.ms, t_start=None,
                   t_stop=None, sampling_period=None, id_column_dat=0,
                   time_column_dat=1, value_columns_dat=2,
                   id_column_gdf=0, time_column_gdf=1, value_types=None,
                   value_units=None, lazy=False):
        assert not lazy, 'Do not support lazy'

        seg = self.read_segment(gid_list, time_unit, t_start,
                                t_stop, sampling_period, id_column_dat,
                                time_column_dat, value_columns_dat,
                                id_column_gdf, time_column_gdf, value_types,
                                value_units)
        blk = Block(file_origin=seg.file_origin, file_datetime=seg.file_datetime)
        blk.segments.append(seg)
        seg.block = blk
        return blk

    def read_segment(self, gid_list=None, time_unit=pq.ms, t_start=None,
                     t_stop=None, sampling_period=None, id_column_dat=0,
                     time_column_dat=1, value_columns_dat=2,
                     id_column_gdf=0, time_column_gdf=1, value_types=None,
                     value_units=None, lazy=False):
        """
        Reads a Segment which contains SpikeTrain(s) with specified neuron IDs
        from the GDF data.

        Arguments
        ----------
        gid_list : list, default: None
            A list of GDF IDs of which to return SpikeTrain(s). gid_list must
            be specified if the GDF file contains neuron IDs, the default None
            then raises an error. Specify an empty list [] to retrieve the spike
            trains of all neurons.
        time_unit : Quantity (time), optional, default: quantities.ms
            The time unit of recorded time stamps in DAT as well as GDF files.
        t_start : Quantity (time), optional, default: 0 * pq.ms
            Start time of SpikeTrain.
        t_stop : Quantity (time), default: None
            Stop time of SpikeTrain. t_stop must be specified, the default None
            raises an error.
        sampling_period : Quantity (frequency), optional, default: None
            Sampling period of the recorded data.
        id_column_dat : int, optional, default: 0
            Column index of neuron IDs in the DAT file.
        time_column_dat : int, optional, default: 1
            Column index of time stamps in the DAT file.
        value_columns_dat : int, optional, default: 2
            Column index of the analog values recorded in the DAT file.
        id_column_gdf : int, optional, default: 0
            Column index of neuron IDs in the GDF file.
        time_column_gdf : int, optional, default: 1
            Column index of time stamps in the GDF file.
        value_types : str, optional, default: None
            Nest data type of the analog values recorded, eg.'V_m', 'I', 'g_e'
        value_units : Quantity (amplitude), default: None
            The physical unit of the recorded signal values.
        lazy : bool, optional, default: False

        Returns
        -------
        seg : Segment
            The Segment contains one SpikeTrain and one AnalogSignal for
            each ID in gid_list.
        """
        assert not lazy, 'Do not support lazy'

        if isinstance(gid_list, tuple):
            if gid_list[0] > gid_list[1]:
                raise ValueError('The second entry in gid_list must be '
                                 'greater or equal to the first entry.')
            gid_list = range(gid_list[0], gid_list[1] + 1)

        # __read_xxx() needs a list of IDs
        if gid_list is None:
            gid_list = [None]

        # create an empty Segment
        seg = Segment(file_origin=",".join(self.filenames))
        seg.file_datetime = datetime.fromtimestamp(os.stat(self.filenames[0]).st_mtime)
        # todo: rather than take the first file for the timestamp, we should take the oldest
        #       in practice, there won't be much difference

        # Load analogsignals and attach to Segment
        if 'dat' in self.avail_formats:
            seg.analogsignals = self.__read_analogsignals(
                gid_list,
                time_unit,
                t_start,
                t_stop,
                sampling_period=sampling_period,
                id_column=id_column_dat,
                time_column=time_column_dat,
                value_columns=value_columns_dat,
                value_types=value_types,
                value_units=value_units)
        if 'gdf' in self.avail_formats:
            seg.spiketrains = self.__read_spiketrains(
                gid_list,
                time_unit,
                t_start,
                t_stop,
                id_column=id_column_gdf,
                time_column=time_column_gdf)

        return seg

    def read_analogsignal(self, gid=None, time_unit=pq.ms, t_start=None,
                          t_stop=None, sampling_period=None, id_column=0,
                          time_column=1, value_column=2, value_type=None,
                          value_unit=None, lazy=False):
        """
        Reads an AnalogSignal with specified neuron ID from the DAT data.

        Arguments
        ----------
        gid : int, default: None
            The GDF ID of the returned SpikeTrain. gdf_id must be specified if
            the GDF file contains neuron IDs, the default None then raises an
            error. Specify an empty list [] to retrieve the spike trains of all
            neurons.
        time_unit : Quantity (time), optional, default: quantities.ms
            The time unit of recorded time stamps.
        t_start : Quantity (time), optional, default: 0 * pq.ms
            Start time of SpikeTrain.
        t_stop : Quantity (time), default: None
            Stop time of SpikeTrain. t_stop must be specified, the default None
            raises an error.
        sampling_period : Quantity (frequency), optional, default: None
            Sampling period of the recorded data.
        id_column : int, optional, default: 0
            Column index of neuron IDs.
        time_column : int, optional, default: 1
            Column index of time stamps.
        value_column : int, optional, default: 2
            Column index of the analog values recorded.
        value_type : str, optional, default: None
            Nest data type of the analog values recorded, eg.'V_m', 'I', 'g_e'.
        value_unit : Quantity (amplitude), default: None
            The physical unit of the recorded signal values.
        lazy : bool, optional, default: False

        Returns
        -------
        spiketrain : SpikeTrain
            The requested SpikeTrain object with an annotation 'id'
            corresponding to the gdf_id parameter.
        """
        assert not lazy, 'Do not support lazy'

        # __read_spiketrains() needs a list of IDs
        return self.__read_analogsignals([gid], time_unit,
                                         t_start, t_stop,
                                         sampling_period=sampling_period,
                                         id_column=id_column,
                                         time_column=time_column,
                                         value_columns=value_column,
                                         value_types=value_type,
                                         value_units=value_unit)[0]

    def read_spiketrain(
            self, gdf_id=None, time_unit=pq.ms, t_start=None, t_stop=None,
            id_column=0, time_column=1, lazy=False, **args):
        """
        Reads a SpikeTrain with specified neuron ID from the GDF data.

        Arguments
        ----------
        gdf_id : int, default: None
            The GDF ID of the returned SpikeTrain. gdf_id must be specified if
            the GDF file contains neuron IDs. Providing [] loads all available
            IDs.
        time_unit : Quantity (time), optional, default: quantities.ms
            The time unit of recorded time stamps.
        t_start : Quantity (time), default: None
            Start time of SpikeTrain. t_start must be specified.
        t_stop : Quantity (time), default: None
            Stop time of SpikeTrain. t_stop must be specified.
        id_column : int, optional, default: 0
            Column index of neuron IDs.
        time_column : int, optional, default: 1
            Column index of time stamps.
        lazy : bool, optional, default: False

        Returns
        -------
        spiketrain : SpikeTrain
            The requested SpikeTrain object with an annotation 'id'
            corresponding to the gdf_id parameter.
        """
        assert not lazy, 'Do not support lazy'

        if (not isinstance(gdf_id, int)) and gdf_id is not None:
            raise ValueError('gdf_id has to be of type int or None.')

        if gdf_id is None and id_column is not None:
            raise ValueError('No neuron ID specified but file contains '
                             'neuron IDs in column ' + str(id_column) + '.')

        return self.__read_spiketrains([gdf_id], time_unit,
                                       t_start, t_stop,
                                       id_column, time_column,
                                       **args)[0]

class ColumnIO:
    '''
    Class for reading an ASCII file containing multiple columns of data.
    '''

    def __init__(self, filename):
        """
        filename: string, path to ASCII file to read.
        """

        self.filename = filename

        # read the first line to check the data type (int or float) of the data
        f = open(self.filename)
        line = f.readline()

        additional_parameters = {}
        if '.' not in line:
            additional_parameters['dtype'] = np.int32

        self.data = np.loadtxt(self.filename, **additional_parameters)

        if len(self.data.shape) == 1:
            self.data = self.data[:, np.newaxis]

    def get_columns(self, column_ids='all', condition=None,
                    condition_column=None, sorting_columns=None):
        """
        column_ids : 'all' or list of int, the ids of columns to
                    extract.
        condition : None or function, which is applied to each row to evaluate
                    if it should be included in the result.
                    Needs to return a bool value.
        condition_column : int, id of the column on which the condition
                    function is applied to
        sorting_columns : int or list of int, column ids to sort by.
                    List entries have to be ordered by increasing sorting
                    priority!

        Returns
        -------
        numpy array containing the requested data.
        """

        if column_ids == [] or column_ids == 'all':
            column_ids = range(self.data.shape[-1])

        if isinstance(column_ids, (int, float)):
            column_ids = [column_ids]
        column_ids = np.array(column_ids)

        if column_ids is not None:
            if max(column_ids) >= len(self.data) - 1:
                raise ValueError('Can not load column ID %i. File contains '
                                 'only %i columns' % (max(column_ids),
                                                      len(self.data)))

        if sorting_columns is not None:
            if isinstance(sorting_columns, int):
                sorting_columns = [sorting_columns]
            if (max(sorting_columns) >= self.data.shape[1]):
                raise ValueError('Can not sort by column ID %i. File contains '
                                 'only %i columns' % (max(sorting_columns),
                                                      self.data.shape[1]))

        # Starting with whole dataset being selected for return
        selected_data = self.data

        # Apply filter condition to rows
        if condition and (condition_column is None):
            raise ValueError('Filter condition provided, but no '
                             'condition_column ID provided')
        elif (condition_column is not None) and (condition is None):
            warnings.warn('Condition column ID provided, but no condition '
                          'given. No filtering will be performed.')

        elif (condition is not None) and (condition_column is not None):
            condition_function = np.vectorize(condition)
            mask = condition_function(
                selected_data[:, condition_column]).astype(bool)
            selected_data = selected_data[mask, :]

        # Apply sorting if requested
        if sorting_columns is not None:
            values_to_sort = selected_data[:, sorting_columns].T
            ordered_ids = np.lexsort(tuple(values_to_sort[i] for i in
                                           range(len(values_to_sort))))
            selected_data = selected_data[ordered_ids, :]

        # Select only requested columns
        selected_data = selected_data[:, column_ids]

        return selected_data


Adam Scott plays a man who starts to realize his new stepson might be the Antichrist in the upcoming Netflix horror/comedy Little Evil, directed by Tucker and Dale vs Evil director Eli Craig.
The Camp Firewood gang returns to keep their promise from the movie of reuniting 10 years later in the next Wet Hot American Summer series, arriving in August on Netflix.
This week on the podcast, Zach, Chris and Joe talk about the Emmy Awards, time travel, Resident Evil, the start of fall TV, the stupidity of Stealth, a bunch of first look photos and much more.
Another legend passed away this week, the possible villain of The Batman, Stranger Things officially getting Season 2, Duke Nukem is back and much more in this week's News Shotgun.
The first weekend of December has a holiday horror movie and an apparently terrible biopic on Mother Teresa.
A dysfunctional family's holidays are interrupted by the arrival of the ancient entity known as Krampus, who is looking to punish anyone who has misbehaved.
Johnny Depp takes on the role of notorious Boston gangster Whitey Bulger for the upcoming true life crime thriller, Black Mass.
Coming home to clear his name, biker Cary Ford is framed for murder by a rival biker and comes into the crosshairs of Trey, leader of the vicious Reapers gang.


This was good! It's stir-fried broccoli and gardein chick'n strips. The frozen veggie chicken even comes with the pack of teriyaki sauce.
Start the chopped broccoli cooking in a sauté pan.
Heat a 75 gram serving veggie chicken strips in the microwave for 30 seconds on high from frozen. Dice.
Add to the sauté pan and brown.
Defrost the sauce packet in warm water. I only used a small amount of it and refrigerated the remainder.
Remove the pan from the heat and add the sauce.
This page contains a single entry by Rick Kasguma published on November 8, 2017 5:02 PM.
What I ate: November 7, 2017 was the previous entry in this blog.
What I ate: November 8, 2017 is the next entry in this blog.


text:
About Aikido & the Dojo
About USAF
Classes & Schedule
Rules and Etiquette
Eventsadmin@aikidosantabarbara2021-06-24T13:29:49-08:00
Download Event PDF »
Aikido of Santa Barbara
121 N. Milpas Street
aikidoofsantabarbara@gmail.com
Aikido of Santa Barbara is a 501c3 non-profit organization whose mission is to enhance the physical, mental, and spiritual health of youth and families by cultivating their minds and bodies through the knowledge and practice of the traditional Japanese art of Aikido.
© 2023 Aikido of Santa Barbara All Rights Reserved. Privacy Policy

redpajama_set_name: RedPajamaCommonCrawl


text:
JP4205987B2 - Control device for tomographic imaging apparatus and tomographic imaging apparatus - Google Patents
Control device for tomographic imaging apparatus and tomographic imaging apparatus Download PDF
JP4205987B2 JP2003135470A JP2003135470A JP4205987B2 JP 4205987 B2 JP4205987 B2 JP 4205987B2 JP 2003135470 A JP2003135470 A JP 2003135470A JP 2003135470 A JP2003135470 A JP 2003135470A JP 4205987 B2 JP4205987 B2 JP 4205987B2
tomographic
layer position
JP2003325480A (en
エジングマン ニールス
ハルダー マルチン
シーメンス アクチエンゲゼルシヤフトSiemens Aktiengesellschaft
2002-05-15 Priority to DE10221642.8 priority Critical
2002-05-15 Priority to DE2002121642 priority patent/DE10221642B4/en
2003-05-14 Application filed by シーメンス アクチエンゲゼルシヤフトSiemens Aktiengesellschaft filed Critical シーメンス アクチエンゲゼルシヤフトSiemens Aktiengesellschaft
G01R33/00—Arrangements or instruments for measuring magnetic variables
G01R33/20—Arrangements or instruments for measuring magnetic variables involving magnetic resonance
G01R33/44—Arrangements or instruments for measuring magnetic variables involving magnetic resonance using nuclear magnetic resonance [NMR]
G01R33/48—NMR imaging systems
G01R33/483—NMR imaging systems with selection of signals or spectra from particular regions of the volume, e.g. in vivo spectroscopy
G01R33/4833—NMR imaging systems with selection of signals or spectra from particular regions of the volume, e.g. in vivo spectroscopy using spatially selective excitation of the volume of interest, e.g. selecting non-orthogonal or inclined slices
A61B6/00—Apparatus for radiation diagnosis, e.g. combined with radiation therapy equipment
A61B6/02—Devices for diagnosis sequentially in different planes; Stereoscopic radiation diagnosis
A61B6/03—Computerised tomographs
A61B6/032—Transmission computed tomography [CT]
A61B6/46—Apparatus for radiation diagnosis, e.g. combined with radiation therapy equipment with special arrangements for interfacing with the operator or the patient
A61B6/461—Displaying means of special interest
A61B6/465—Displaying means of special interest adapted to display user selection data, e.g. icons or menus
A61B6/467—Apparatus for radiation diagnosis, e.g. combined with radiation therapy equipment with special arrangements for interfacing with the operator or the patient characterised by special input means
A61B6/469—Apparatus for radiation diagnosis, e.g. combined with radiation therapy equipment with special arrangements for interfacing with the operator or the patient characterised by special input means for selecting a region of interest [ROI]
A61B6/48—Diagnostic techniques
A61B6/488—Diagnostic techniques involving pre-scan acquisition
G01N23/00—Investigating or analysing materials by the use of wave or particle radiation not covered by groups G01N3/00 – G01N17/00, G01N21/00 or G01N22/00
G01N23/02—Investigating or analysing materials by the use of wave or particle radiation not covered by groups G01N3/00 – G01N17/00, G01N21/00 or G01N22/00 by transmitting the radiation through the material
G01N23/04—Investigating or analysing materials by the use of wave or particle radiation not covered by groups G01N3/00 – G01N17/00, G01N21/00 or G01N22/00 by transmitting the radiation through the material and forming images of the material
A61B5/72—Signal processing specially adapted for physiological signals or for diagnostic purposes
A61B5/7271—Specific aspects of physiological measurement analysis
A61B5/7285—Specific aspects of physiological measurement analysis for synchronising or triggering a physiological measurement or image acquisition with a physiological event or waveform, e.g. an ECG signal
A61B6/54—Control of devices for radiation diagnosis
A61B6/541—Control of devices for radiation diagnosis involving acquisition triggered by a physiological signal
G01R33/54—Signal processing systems, e.g. using pulse sequences, Generation or control of pulse sequences ; Operator Console
G01R33/546—Interface between the MR system and the user, e.g. for controlling the operation of the MR system or for the design of pulse sequences
Y10S378/00—X-ray or gamma ray systems or devices
Y10S378/901—Computer tomography program or processor
In the present invention, a reference image of an object is displayed using a graphic user screen, and a position of a tomographic image to be subsequently imaged is determined by a layer position mark in the displayed reference image. Control of a tomographic imaging device that captures tomographic images apparatus About. Furthermore, the present invention This kind of The present invention relates to a tomographic imaging apparatus including a control device.
Tomographic imaging devices such as X-ray computer tomographs and nuclear spin tomographs are particularly applied in the medical field. In many cases, tomographic imaging devices are used to examine a body part or organ of a patient for subsequent diagnosis. Furthermore, tomographic imaging devices are often used in surgery. For example, a method in which a relatively accurate three-dimensional display of a surgical region is first performed by a magnetic resonance apparatus before surgery is already known (see, for example, Patent Document 1). In addition, ultrasonic image data of the surgical region can be acquired using the ultrasonic head before the operation and at various times during the operation. By comparing the ultrasonic image data acquired at various points in time, changes in the surgical region are obtained, and based on these changes, a three-dimensional magnetic resonance data set is updated and displayed. This method creates a sufficiently detailed "artificial magnetic resonance image" by a relatively simple ultrasonic imaging method when a correspondingly finely operated magnetic resonance imaging method cannot be used during surgery. Enable.
In addition, there are a variety of tomographic methods for inspecting any other object without destroying it.
When this type of tomography is used, it is desirable in principle that a person to be inspected or an object to be inspected is captured by imaging as few times as possible, and as a result, clear and reliable inspection results can be obtained. This is particularly important in the medical field. This is because the examination time and, in some cases, the radiation load, which are usually unpleasant for the patient, are reduced. For this purpose, the position of the tomographic image to be imaged is selected so that the inspection object, that is, the part to be examined inside the human (for example, a specific organ of the patient) is properly captured on the tomographic image. is required.
However, it is not always possible to accurately position the region of interest from the outside in advance, particularly in patient examination. This is because, first of all, the exact location of an organ in the patient's body is related to the patient's personal anatomy, and secondly to which region of the organ to be examined in detail. This is because the presence of abnormal (in some cases) abnormal lesions is often revealed only during the course of the examination.
Currently, the control methods listed at the beginning are usually used in order to accurately position the tomographic image. In this case, as the reference image, for example, a standard tomographic image of a subject, that is, a body part to be examined (for example, the head or the chest cavity) is created in the initial stage. The reference image is usually captured inside the tomographic image capturing apparatus itself. In principle, it is also possible to use tomograms created by other devices, but this is only possible if the patient to be examined can be properly positioned in the tomography system based on the outer anatomy. Limited. Next, the operator of the tomographic imaging apparatus places the layer position mark in the reference image by using an appropriate input device such as a normal computer mouse, graphic tablet, keyboard or the like, for example, in the form of cross lines and / or projections. In the medical field, a sagittal cross-sectional image (sagittal image), a coronal cross-sectional image (coronal image), and a transverse cross-sectional image (axial image) are often created as reference images. In order to define a single plane in the 3D inspection object, usually one layer position mark is formed in the form of an intersection line on two of the three images, and in the third image the shape of the projection view. Thus, another layer position mark is required. In addition, the layer size and thickness can be set. As a rule, the same plurality of layers to be imaged, for example a plurality of parallel layers, are marked in the reference image, so that the desired area of the structure to be examined can be best captured. This very comfortable method for the operator, which determines the position of the tomographic image to be imaged by marking in the reference image of the object, is called "graphic layer positioning" (GSP). For each tomographic image to be imaged, several other parameters necessary for controlling the tomographic imaging apparatus can be set. In the nuclear spin tomograph, this is, for example, the relaxation time TA and the echo time TE, and in the X-ray computer tomograph, it is an irradiation dose to be set. If the operator has set all parameters and the measurement area is adequately covered by the planned layer, the measurement is initiated by a so-called "measurement queue". Next, the data of the layer position mark in the reference image is converted into the position data in the object to be inspected, and the tomographic imaging apparatus or the scanner creates a desired image at the layer position in the inspection object. Controlled. Next, the created tomographic image is stored in the image data bank. All measured images can be used directly for subsequent layer positioning. That is, these images can also be used to input a new layer position mark for subsequent measurement as a reference image on the graphic user screen.
Various methods for creating a tomographic image by graphic layer positioning are described in, for example, two other patents (see, for example, Patent Document 2 and Patent Document 3).
In this case, Patent Document 2 proposes a method in which a reference image rotated by a user in relation to input of a corresponding command and a three-dimensional display of a layer corresponding to the rotation of the reference image are created on the display. ing. According to this method, it is advantageous for the user that the three-dimensional position of the selected layer to be measured is visualized with respect to a reference image of the measured body part of the patient. Especially in the case of double-tilted layer groups, each user can understand the actual situation very easily, and the planned or displayed layer in the reference image actually shows the area or body part to be examined. The user does not have to use a particularly high degree of three-dimensional imagination for this purpose.
Also in Patent Document 3, it is proposed to perform rough imaging of an object perpendicularly to a desired layer, and then to position the desired layer graphically based on this rough imaging. Subsequently, a 3D data set including a preset layer is created. The desired layer is then reconstructed from this 3D data set and finally displayed.
However, all the above methods cause problems when the position of the object changes perpendicular to the desired image plane over time. In such a case, the structure of interest is no longer completely displayed. Therefore, it is necessary to track the image plane according to the movement. A typical example in this regard is examination of a patient's heart valve. The position of the heart valve changes constantly with respiration and heart motion. It is usually not possible in the case of two-dimensional imaging to simultaneously derive the motion information of the object of interest for image tracking. This is because the structure to be examined (eg heart valve) is too small and is often relatively difficult to differentiate. Furthermore, the motion measurement and the image measurement need to be performed separately in time, in which case the motion measurement affects the image signal. Therefore, in practice, an indirect method is used in which the motion component of interest of the structure to be originally examined is determined from the motion of other structures (for example, other organs of the patient). In this case, a frequently used method is the so-called "navigator echo method", in which the signal and position of the reference structure are detected by the tomographic imaging apparatus, for example, the current position of the reference structure and the structure to be inspected. A linear connection between is determined. By using this method, for example, the position of the diaphragm is measured, and as a result, the respiratory position of the heart can be corrected. The disadvantage of this method is that not only the structure to be inspected but also the reference structure must be measured continuously in order to determine the deviation. For this reason, a part of the measurement time can no longer be used to measure the originally desired structure. This problem exists in all methods that use a reference structure to track the measurement layer. In addition, the so-called "slice tracking method" is also known, in which the motion of the structure is pre-measured as a function of time from actual use and the measurement layer motion is pre-calculated from the result. This method has the disadvantage that it can only be applied in certain structures (eg, the patient's diaphragm and liver) that are large enough for this type of examination. Moreover, this method is not applicable to a relatively small structure such as a heart valve. In such a case, it is necessary to apply again an indirect method in which the motion of the heart valve is estimated from, for example, the upper myocardium of the heart.
[Patent Document 1]
German Patent No. 19846687
German Patent Application Publication No. 10048438
[Problems to be solved by the invention]
The subject of the present invention is universally applicable to various inspections, and in particular, the position of a tomographic image can be reliably traced, and as a result, a small structure to be inspected can be observed reliably over a relatively long time. , Tomographic imaging that makes time-related layer positioning easy Apparatus control apparatus and tomographic imaging apparatus Is to provide.
[Means for Solving the Problems]
This task Of the tomographic imaging device according to claim 1 Control device or claim 9 This is solved by the tomographic imaging apparatus.
According to the invention, first a sequence of layer position marks relating to time, ie at least two layer position marks, is placed in the reference image. In this case, one time mark is assigned to each layer position mark. Each time mark is associated with a time mark of a particular reference time point or other layer position mark of the sequence, i.e. individual layer position marks are assigned, for example, relative time intervals. Next, using this sequence of time-related layer position marks, the position of the tomographic image to be subsequently imaged is relative to the reference time point (for example, the start time of the measurement or the image time point of the preceding tomographic image). It is determined in relation to the time when each tomographic image is captured.
By linking each layer position mark to a time mark, the operator can interactively indicate the position of each image plane, thereby indicating any sequence of imaging within the object as a function of time. it can. That is, the operator can accurately plan the subsequent measurement series with respect to the time component, so that it can be appropriately matched to the respective examination. In this case, the motion of the structure of interest is also taken into account, so that no expensive extra measurements are required to track the image plane.
The term "layer position" refers not only to the determination of the layer position in this specification, but also to the orientation of the layer and possibly the shape and volume of the layer at a specific position, ie the position of each volume element. It is. In this respect, the layer is not only a flat parallel plane layer but also a hyperplane. However, for the sake of brevity, in the following, it is assumed that the flat tomographic image is positioned without limiting the invention.
Control device according to the invention Requires a normal user interface with a graphic user screen for displaying a reference image and means for placing layer position marks. In addition, there is a need for a layer position detection unit for determining the position of a tomographic image to be subsequently imaged of the object using the layer position mark in the reference image. The position in the object can be obtained from the layer position mark by, for example, simply converting graphic data into position coordinates in the measurement object. Furthermore, control means for controlling the tomographic imaging apparatus so as to capture a tomographic image of the object at a position determined by the layer position detection unit is also necessary. This includes, for example, an interface, a D / A transformer for controlling various components (servo motor and electromagnet) of the tomographic imaging apparatus, a magnetic resonance signal transmission / reception coil, and the like. According to the invention, the control device also has means for placing a sequence of layer position marks relating to time in the reference image and assigning one time mark to each individual layer position mark of the sequence. There must be. Furthermore, the layer position detection unit uses the sequence of the layer position marks related to time to determine the position of the tomographic image to be subsequently imaged relative to the reference time point relative to the time point of each tomographic image. Must be configured to.
All dependent claims contain particularly advantageous embodiments of the invention.
A series of tomographic images to be imaged at various times is determined in one reference image or in two or three reference images that display the object from various points of view at a particular time. However, in a particularly preferred embodiment, a sequence of time-related reference images is first created that displays the object at different relative time points relative to the reference time point or at a determined time interval. For this purpose, the control device stores means for creating a sequence of time-related reference images and recording information relating to the relative time points of the reference images, together with the time information. It is desirable to have a reference image storage device. A sequence of time related layer position marks is placed in this sequence of time related reference images. An operator can obtain information about how a particular tomogram is properly positioned at a particular relative time point using a time-related reference image, and this also enables layer position Marks can also be placed.
It is particularly desirable if the relative position of the reference image itself is automatically assigned as a time mark to a layer position mark placed in the reference image relating to time. It is also desirable that the layer position mark be accurately placed in each of the time related reference images. The control device needs to have an assigning means for assigning relative time points of the respective reference images as time marks to the layer position marks.
In particular, a sequence of reference images relating to time is generated during a process corresponding to the process during the subsequent measurement of the tomographic image for inspection. This is a process that is repeated periodically (for example, a patient's breathing motion or heart motion), or a process that is performed only once (for example, a swallowing motion). For example, to examine the esophagus during a swallowing exercise, the patient first swallows the contrast agent. A sequence of reference images is taken during this first swallowing movement. Next, the operator of the tomographic imaging apparatus places a layer position mark in this reference image to determine at which relative time point in which region of the esophagus the tomographic image should be created. Subsequently, the original examination is performed during the iteration of the swallowing process.
The sequence of time-related reference images in particular requires that the particular motility structure to be imaged of the object (eg heart valve) has to be displayed in other positions each time, ie at least one of the direction of motion of the structure of interest The component is preferably located in the image plane of the reference image relating to time. Next, a layer position mark is placed in each of the time-related reference images so that the layer of the object containing this structure of the object is marked. That is, in the examination of the heart valve, for example, the layer position mark is placed such that the heart valve is included in each of the reference images where the marked layer is time related.
In a very simple example, in the subsequent measurement series, a plurality of tomographic images are respectively taken at the time when they coincide with the time marks of the layer position marks. Next, this tomographic image is accurately picked up at a position corresponding to the layer position mark.
It is also desirable to create a time related positioning function and / or reference table using a sequence of time related layer position marks. Based on this time-related positioning function or reference table (lookup table), the position of the tomographic image can then be determined at any relative imaging time point. In this case, the data of the sequence of layer position marks relating to time form, for example, function sample points (or interpolation points) or look-up table entries or sample points (for creating more complex look-up tables). Or an interpolation point). The positioning function is performed using conventional mathematical methods such as creating a function based on sample points (or interpolation points), such as any suitable fitting and interpolation methods. In some cases, this may be done by dividing the time. Similarly, the lookup table can be complemented between each sample point (or interpolation point) using an appropriate interpolation method at the time of creation. In the case of using a lookup table, a known interpolation method can be similarly used in order to obtain a position for an imaging time point existing between values entered in the lookup table.
Accordingly, the relative time points of the individual tomographic images in the subsequent measurement series can be selected regardless of the temporal position of the reference image used. This makes it possible to create only a small number of reference images at large time intervals for positioning the graphic layer according to the present invention, and subsequently to capture a relatively dense tomographic image series in the original examination. First, the total inspection time is shortened. Secondly, the number of reference images can be reduced to a minimum, especially during examination by X-ray computed tomography, thereby reducing the patient's radiation exposure time.
Therefore, it is desirable that the control device includes means for executing one imaging series. In that case, the start time of the imaging series can be used as a reference time for determining the position of each tomographic image in relation to each imaging time.
In this case, it is conceivable to select an occurrence time point of an event occurring in the object as a reference time point, that is, a start time point. This type of event is, for example, the start of the swallowing process already mentioned or a specific event in the heart movement during a cardiac examination, eg the occurrence of a typical r-wave or s-wave in the ECG (electrocardiogram) of the patient to be examined. The triggering of MR simple imaging by ECG r-wave is, for example, Y.R. Liu, S .; J. et al. Riederer, D.M. G. Brown, R.A. C. Wright, A.M. E. Holsinger, R.A. C. Grimm, R.A. L. Proposed by Ehman, "ECG-triggered snapshot MR imaging of the heart" (Computer in Cardiology 1990, Minutes 23.-26. September 1990, p381-384).
For this purpose, it is desirable if the control device has means for measuring an event in the object as a reference time, for example a suitable measuring device. Alternatively, the signal of an external measuring device connected to the control device via the interface can be used. The measuring device automatically generates a trigger signal when an event occurs, and this trigger signal starts the imaging series.
In this case, the imaging series can be repeated periodically. For example, in a cardiac examination, multiple image series can be taken each time within an rr interval measured by ECG, and a new r wave can be triggered each time. In this case, it is not always necessary to create a tomographic image in each image series at the same relative time point as the reference time point. In each image series, tomographic image capturing can be performed at individual time points. Are newly determined in relation to the relative imaging time points.
For the most part, the control device according to the invention can be realized in the form of suitable software on a computer with sufficient computing power. This computer may be a normal computer provided with an interface for controlling the tomographic imaging apparatus.
In particular, a layer position detection unit that determines the exact position of the tomographic image in the object based on the layer position mark in the reference image and calculates the position in relation to the relative imaging time point is a software module in the form of a software module. It may be installed on the processor.
The part of the user interface that selects the image data to be displayed on the graphic user screen, converts the command of the mouse, keyboard or similar input device into data, and thereby places the mark on the graphic user screen Can also be realized on this processor or on a separate computer having a user interface as a terminal.
Furthermore, a device for automatically controlling a tomographic imaging device for imaging a reference image series or a subsequent original inspection image series, means for recording information on the relative time of the reference image, and layers The assigning means for assigning the relative time of the reference image to the position mark as a time mark and the means for determining the positioning function and / or the reference table from the reference data can be realized in the form of a software module.
Accordingly, since the control device of the existing tomographic imaging apparatus can be changed relatively easily, the tomographic imaging apparatus can be operated according to the method of the present invention.
The present invention will be described in detail below with reference to the accompanying drawings with reference to the accompanying drawings.
A tomographic imaging apparatus 1 shown in FIG. 1 is a nuclear spin tomograph 1, in which a patient to be examined is laid on a patient bed.
The nuclear spin tomograph 1 is controlled by a control device 2. The control device 2 mainly comprises a large computer 7 and a terminal device 3 connected to the computer 7. An operator can operate the control device 2 or the nuclear spin tomograph 1 through this terminal. For this purpose, the terminal 3 has user interfaces 4, 5, 6, B including a normal display 6 on which a graphic user screen B is displayed, a keyboard 4 and a mouse 5.
Here, the nuclear spin tomograph 1 is connected to the control device 2 via the interfaces 12 and 13. In practice this is usually a plurality of individual interfaces for controlling individual components of a nuclear spin tomograph, for example a transmitting coil, a receiving coil or each magnet or for receiving image data. However, for the sake of clarity, only a common interface 12 for controlling the nuclear spin tomograph 1 and an interface 13 for receiving image data from the nuclear spin tomograph 1 are shown here.
As an alternative, it is also possible to integrate the entire control device 2 in the nuclear spin tomograph.
In addition to the interfaces 12 and 13 described above, the computer 7 of the control device 2 includes a processor (for example, a CPU having sufficient calculation capability) 9, a mass storage device 10, an interface 11 for connecting to the terminal 3, and a measuring device ( For example, another interface 14 for connecting to an ECG measuring device 21 is provided. All these components are connected to each other with the bus 8.
In the processor 9, a program necessary for controlling the nuclear spin tomograph 1 proceeds. The control software necessary for this purpose is indicated by a broken line as a control software module 15 in the figure. This control software module 15 includes submodules 16, 17, 18, 19, 20 suitable for performing the method according to the invention.
Of course, in addition to the components shown, the computer 7 has other hardware components (eg, mass RAM storage, conversion data storage, etc.) and software components (eg, operating systems) that are typically present in this type of computer 7. System). These components are not shown for clarity. This is because the exact configuration of the computer, ie, the hardware configuration and software configuration, does not have a significant effect on the present invention as long as it is mentioned. Similarly, it is suggested that a user interface portion such as the display 6, the keyboard 4 or the mouse 5 can be directly connected to the computer 7 instead of using the separate terminal 3. The terminal device 3 can also take over the duties of the control software module 15 as a workstation, for example. For example, the terminal 3 can be provided with a unique image storage device for storing a reference image or the like.
On the graphic user screen B of the terminal 3, a reference image R is displayed for measurement planning, and an object O is displayed on the reference image R. Next, the position of the tomographic image to be subsequently imaged by the mouse 5 and / or the keyboard 4 in these reference images R is determined in the form of intersecting lines passing through the layer position mark M, here the object O. The position data of the layer position mark M in the reference image R is transmitted to the control software module 15 of the processor 9 via the interface 11 and the bus 8.
In the following, in the layer position detection module 16 called the GSP module 16, the position corresponding to the layer position mark M of the desired tomographic image on the object O itself is calculated. Next, the control software module 15 controls each component of the nuclear spin tomograph 1 via the bus 8 and the control interface 12 so that a tomographic image is captured at a desired position. The captured tomographic data is returned to the computer 7 via the interface 13 where it is stored in the mass storage device 10 and / or displayed directly on the display 6 of the terminal 3. The operator can display an arbitrary tomographic image from the mass storage device 10 on the display 6 by inputting to the graphic user screen via the keyboard 4 or the mouse 5 at any time, for example, by inputting to the menu displayed there. Can be made.
An output device, for example a printer, is connected to the control device 2 in order to output the tomographic image at any time continuously, for example, in the form of a negative on paper or foil. However, this output device and the interface for connecting to the bus 8 are not shown in the figure.
In the embodiment according to the invention according to FIG. 1, the control software module 15 has an image sequence creation module 18, i.e. another subroutine, which is a time-related reference image R according to the operator's command via the terminal 3. 1 ~ R 6 Create a sequence of These reference images R 1 ~ R 6 At the time of creation, one relative imaging time point is assigned, that is, associated with each other.
This is shown as the first method step I in the flowchart according to FIG. In the next method step II, a time-related reference image R 1 ~ R 6 Are loaded into the GSP module 16 and / or the mass storage device 10. The mass storage device 10 includes a reference image storage device RBS, where the reference image R 1 ~ R 6 The series of is memorized and can be called again at any time from there. Next, the GSP module 16 uses the reference image R related to time. 1 ~ R 6 Is displayed on the user screen B of the terminal 3 automatically or in response to an operator's call.
Reference image R related to six times 1 ~ R 6 This type of series is shown in FIG. Here, the reference image R 1 ~ R 6 The object O displayed above is roughly illustrated by a dashed ellipse. Within the object O there is a structure S, shown here as a horizontal bar within the lower third of this ellipse for ease of understanding. Each of these reference images R 1 ~ R 6 Is the reference image R 1 ~ R 6 The images are taken at different imaging times displayed in the figure. For example, the first reference image R 1 Is imaged 100 ms after the reference time point, and the second reference image R 2 Is taken after 200 ms from the reference time point and continues in the same manner as shown in FIG.
Next, each reference image R in method step III according to FIG. 1 ~ R 6 Inside layer mark M 1 ~ M 6 Is placed. This is because the reference image R illustrated by the operator with the keyboard 4 and / or the mouse 5 is shown. 1 ~ R 6 This is done by entering a broken line or a projection in the usual way.
Reference image R shown in FIG. 1 ~ R 6 This is shown schematically in FIG. Individual layer position mark M 1 ~ M 6 Are shown here as wide horizontal bars, each of which is an individual reference image R 1 ~ R 6 Covers the structure of interest S of the object O. Accordingly, after that, tomographic images each accurately indicating the structure S are taken.
In this case, the individual layer position mark M 1 ~ M 6 Each reference image R 1 ~ R 6 Relative image capturing time points are assigned as time marks TT. This allocation is performed by a lower level routine of the allocation device 19, here the GSP module 15.
Next, the layer position mark M to which the time mark TT is attached 1 ~ M 6 These data are continuously processed in the GSP module 16. For this purpose, the GSP module 16 uses a layer position mark M with a time mark TT. 1 ~ M 6 Is provided with another software module 20 for creating a lookup table (reference table) LUT. This type of lookup table LUT is as follows, for example.
[Lookup table LUT]
Time TT Origin position Layer normal In-plane vector
(Unit: ms) (LPH) (LPH) (LPH)
100 p [l, p, h] (1) n [l, p, h] (1) v [l, p, h] (1)
In this embodiment, a time mark TT indicating a relative time point is entered in the first column. Each of the other three columns shows position data p, n, and v necessary for uniquely defining the position of each tomographic image.
In the embodiment shown, the second column shows the defined origin p of the layer, for example the coordinates of the geometric center point or the defined corners of the tomogram.
The third column shows the layer normal n protruding from the layer plane, ie the vector coordinates. Reference image R in FIG. 1 ~ R 6 The layer normal vector is the layer position mark M 1 ~ M 6 In this case, the origin is any layer position mark M. 1 ~ M 6 Is the intersection of and the arrow.
The origin and the layer normal vector are parameters necessary for determining the position of a flat parallel plane two-dimensional tomographic image.
In the illustrated lookup table, an in-plane vector indicating the edge orientation of the tomographic image is added as a third parameter. This in-plane vector is a vector that determines the direction of the first row of the imaged two-dimensional tomographic image. This in-plane vector is a selective parameter, but in principle can always be retained. The use of in-plane vectors is advantageous when the structure to be observed not only moves laterally with respect to the tomographic image plane but also rotates in the tomographic image plane. This rotational motion can be canceled out by changing the in-plane vector with time.
If complex tomographic images, such as hyperplanes or tomographic images with different thicknesses, must be displayed, other parameters should be determined accordingly and entered in the lookup table or taken into account when determining the positioning function There is.
In the look-up table shown, each individual parameter is displayed in a coordinate system (LPH) defined by the patient's position. The first coordinate L (left) is the direction to the left of the patient, the second coordinate P (back) is the direction to the back of the patient, and the third coordinate H (head) is the patient's head. Extends in the direction. The origin of the coordinate system for the patient's anatomy is determined by measurement. Usually the origin is the center point of the nuclear spin tomograph. This is because the magnetic field is very homogeneous there. Accordingly, the patient is positioned so that the area to be measured is located near the center point of the nuclear spin tomograph. Thereby, the origin is likewise located close to the structure to be examined, for example in the immediate vicinity of the heart when measuring the heart.
The lookup table LUT is stored in the lookup table LUT in order to use the position data related to the tomographic image time as a sample point (or interpolation point) stored in the subsequent measurement, and at any time. It can be used to determine the exact position of each by interpolation between numerical values. This is done in the lower level routine of the layer calculation unit 17, here also the GSP module 15.
In the flow chart according to FIG. 2, the original subsequent measurement starts after method step V. Here, the exact layer position for the imaging time T is determined using the look-up table LUT. Subsequently, a tomographic image is accurately captured at the imaging time T.
In the next method step VII, it is determined whether a new tomographic image should be taken. If imaging is to be performed, a new calculation of the layer position for the new time T is performed again in method step V or the like. If all the desired tomographic images have been finally taken, the measurement is stopped at method step VIII.
An example of a measurement sequence to be imaged is shown schematically in FIG. Here, a total of twelve tomographic images S in the measurement order. 1 ~ S 12 Has been created. Each time of imaging is the reference image R 1 ~ R 6 As in the case of, after 100 to 600 ms, the imaging time T is the reference image R 1 ~ R 6 Relative imaging time points, that is, individual layer position marks M 1 ~ M 6 Must coincide with the time mark TT.
For example, the optimal reference time T for heart valve examination 0 In order to select the ECG, the patient's ECG is measured continuously during the examination, and the ECG event is measured at the reference time T 0 Is used as a trigger signal for determining. This is illustrated in FIG. In this figure, the ECG clearly shows a typical pqr-s-t course. The obvious rise of the r wave begins with the reference image R 1 ~ R 6 In addition to triggering a measurement to create a series of events, it then appears as an event E to trigger the original measurement. For this reason, in the embodiment shown in FIG. 1, the control device has an ECG device 21 connected to the computer 7 via the interface 14. The ECG device 21 records the rise of the r wave and transmits a trigger signal TS to the computer 7. Next, the trigger signal TS is used as a start signal for starting the measurement of the reference image or at the subsequent original inspection.
As this example shows, the present invention allows the operator to interactively determine any layer position as a function of time. In this case, no additional measurement is necessary in principle. However, the method according to the invention can always be linked to an automatic method for determining the layer position. For example, if a known normal slice tracking method is used, sample points (or interpolation points) can be automatically calculated in advance and displayed on the user screen in graphic positioning, and as a result, this method can be used when planning an inspection. Can also be speeded up. In this case, the operator can accept these displayed layer position marks at any time and can arbitrarily change or delete them.
The method according to the invention has the further advantage that the motion of the structure to be examined can be displayed with much better spatial resolution and with multiple orientations. As a result, more accurate positioning than other methods can be performed.
In addition, an algorithm or other method is provided for presetting the position of the layer related to time in three dimensions. The method according to the invention also has the advantage that the original measurement can be carried out without additionally recording the time-related position during the examination. Therefore, the original measurement can be performed more quickly.
The method according to the invention is particularly advantageous when imaging periodic motion. In addition, unlike other methods, it is also possible to determine a layer shift that is not related to periodic motion.
The preset layer positioning is not limited to a two-dimensional plane. Rather, as described above, the present invention can be expanded and applied to the presetting of the three-dimensional volume and the hyperplane. Although the present invention has been described primarily in the medical field, it is not limited to this type of application.
FIG. 1 is a schematic diagram of a tomographic imaging apparatus provided with a control apparatus according to the present invention.
FIG. 2 is a flow chart of a method progress when an inspection is planned and executed by the method according to the present invention.
FIG. 3 is a schematic diagram of a sequence of reference images related to time.
4 is a sequence diagram of a reference image according to FIG. 3 in which layer position marks have been entered.
FIG. 5 is a schematic view of the position of an object to be measured and the position of a tomographic image to be imaged in a series of individual tomographic images taken 12 times at different relative time points.
FIG. 6 is a diagram showing an ECG measurement result for using an ECG r-wave as a reference time point for tomographic imaging.
[Explanation of symbols]
1 Tomographic imaging device
2 Control device
4 User interface
7 Computer
15 Control software
16 layer position detection unit
21 Measuring device
M layer position mark
R reference image
S tomogram
User interface (4, 5, 6, B) having a graphic user screen (B) for displaying the reference image (R, R 1 to R 6 ) of the object (O) and the displayed reference image a layer position marks (R 1 to R 6) the (M, M 1 ~M 6) means for placing the (4,5),
The position of the tomographic image (S 1 to S 12 ) to be subsequently imaged of the object (O) using the layer position mark (M, M 1 to M 6 ) in the reference image (R, R 1 to R 6 ). A layer position detection unit (16) for determining
Control means for controlling the tomographic imaging apparatus (1) so that the tomographic images (S 1 to S 12 ) of the object (O) are captured at the positions determined by the layer position detection unit (16) ( In the control device (2) of the tomographic imaging device (1) for capturing a tomographic image of the object (O) provided with
Control device (2) is the reference image (R 1 to R 6) Place the sequence of layer position marks related (M 1 ~M 6) in time within an individual layer position mark of the sequence (M 1 ~M 6 ) Each including means (18) for assigning one time mark (TT),
The layer position detection unit (16) uses the sequence of the layer position marks (M 1 to M 6 ) related to time to determine the position of the tomographic image (S 1 to S 12 ) to be subsequently imaged as a reference time point (T 0 )) is determined in relation to the imaging time (T) of each of the tomographic images (S 1 to S 12 ).
Create a sequence of time-related reference images (R 1 -R 6 ) showing the object (O) at different relative time points and record information about the relative time points of the reference images (R 1 -R 6 ) control device according to claim 1, wherein the means (18) is provided for.
A reference image storage device (RBS) for storing a sequence of time-related reference images (R 1 to R 6 ) showing the object (O) at different relative time points together with information on the relative time points. control device according to claim 1 or 2, wherein the provided.
Reference image relating to the time (R 1 ~R 6) dividing the relative time point of the reference image (R 1 ~R 6) to the layer position mark (M 1 ~M 6) placed within a time mark (TT) control device according to one of claims 1 to 3, wherein the allocation means (19) is provided for applying.
The control device comprises means (20) for determining a time-related positioning function and / or reference table (LUT) using a sequence of time-related layer position marks (M 1 to M 6 );
The layer position detection unit (16) is tomographic images (S 1 to S 12 ) to be imaged at any defined relative imaging time point (T) based on the positioning function and / or reference table (LUT) during the subsequent measurement. control device according to one of claims 1 to 4, characterized in that it is configured to determine the position of).
Means (15) for carrying out the imaging series is provided, and the starting time point of the imaging series is for determining the position of each tomographic image (S 1 to S 12 ) in relation to each imaging time point (T). control device according to one of claims 1 to 5, characterized in that a reference time (T 0) of.
Claims 1 to 5, characterized in that the means for determining a reference time (T 0) the occurrence time of a particular event (E) (14,21) is provided for generating in the object (O) The control apparatus as described in one of these.
A measuring device (21) for measuring the event (E) of the object (O) is provided, and this measuring device (21) automatically triggers an imaging series (TS) when the event (E) occurs. 8. The control device according to claim 6 or 7, wherein:
Having a control device according to one of claims 1 to 8, the tomographic image capturing apparatus for capturing a tomographic image of the object.
JP2003135470A 2002-05-15 2003-05-14 Control device for tomographic imaging apparatus and tomographic imaging apparatus Expired - Fee Related JP4205987B2 (en)
DE10221642.8 2002-05-15
DE2002121642 DE10221642B4 (en) 2002-05-15 2002-05-15 Method and control device for controlling a tomographic image recording device
JP2003325480A JP2003325480A (en) 2003-11-18
JP2003135470A Expired - Fee Related JP4205987B2 (en) 2002-05-15 2003-05-14 Control device for tomographic imaging apparatus and tomographic imaging apparatus
US5915380A (en) 1997-03-14 1999-06-29 Nellcor Puritan Bennett Incorporated System and method for controlling the start up of a patient ventilator
US7349564B2 (en) * 2003-01-21 2008-03-25 Elekta Ab (Publ) Imaging internal structures
US7053617B2 (en) * 2003-10-01 2006-05-30 General Electric Co. Integrated electronic RF shielding apparatus for an MRI magnet
DE10357203B4 (en) * 2003-12-08 2018-09-20 Siemens Healthcare Gmbh Method and control device for operating a magnetic resonance tomography device and magnetic resonance tomography device
DE102004003081A1 (en) * 2004-01-21 2005-08-18 Siemens Ag Determination method for the position of the contrast bolus using magnetic resonance, whereby multiple sectional images are recorded at right angles to the blood vessel and in each image the position of the blood vessel determined
DE102004017478B4 (en) * 2004-04-08 2012-01-19 Siemens Ag Device for obtaining structural data of a moving object
DE102005000714A1 (en) * 2005-01-03 2006-07-20 Siemens Ag Medical imaging method for imaging a periodically moving object area, e.g. heart or lungs, by recording of general object area image data, addition of markers, subsequent periodic imaging and then interpolation of marker positions
DE102005001325B4 (en) * 2005-01-11 2009-04-09 Siemens Ag Method for aligning a graphic object on an overview image of an object
DE102005005916A1 (en) * 2005-02-09 2006-08-17 Siemens Ag Method and tomography apparatus for generating tomographic images of a beating heart
US7367502B2 (en) * 2005-09-13 2008-05-06 En-Vision America, Inc. Delivery of item specific audible information via voice server
JP2007075387A (en) * 2005-09-15 2007-03-29 Ge Medical Systems Global Technology Co Llc Breath-holding mr imaging method, mri apparatus, breath-holding tomographic imaging method, and tomographic imaging apparatus
US8021310B2 (en) 2006-04-21 2011-09-20 Nellcor Puritan Bennett Llc Work of breathing display for a ventilation system
DE102006025915A1 (en) 2006-06-02 2007-12-06 Siemens Ag Heart representing method for magnetic resonance system, involves computing image plane for representing heart using identification points that are configured on overview screen, and incorporating magnetic resonance-image in computed plane
US7784461B2 (en) 2006-09-26 2010-08-31 Nellcor Puritan Bennett Llc Three-dimensional waveform display for a breathing assistance system
US20080072902A1 (en) * 2006-09-27 2008-03-27 Nellcor Puritan Bennett Incorporated Preset breath delivery therapies for a breathing assistance system
DE102007014723A1 (en) * 2007-03-23 2008-11-27 Gesellschaft für Schwerionenforschung mbH (GSI) Planning target volume determination method for use in particle therapy system, involves determining target volume equivalent to minimum target volume in fictive homogeneous body, and extending equivalent target volume by a safety margin
US8934604B2 (en) * 2007-09-28 2015-01-13 Kabushiki Kaisha Toshiba Image display apparatus and X-ray diagnostic apparatus
US8755635B2 (en) * 2008-08-11 2014-06-17 Siemens Aktiengesellschaft Method and system for data dependent multi phase visualization
US8924878B2 (en) 2009-12-04 2014-12-30 Covidien Lp Display and access to settings on a ventilator graphical user interface
US8335992B2 (en) 2009-12-04 2012-12-18 Nellcor Puritan Bennett Llc Visual indication of settings changes on a ventilator graphical user interface
USD638852S1 (en) 2009-12-04 2011-05-31 Nellcor Puritan Bennett Llc Ventilator display screen with an alarm icon
USD649157S1 (en) 2009-12-04 2011-11-22 Nellcor Puritan Bennett Llc Ventilator display screen with a user interface
US9119925B2 (en) 2009-12-04 2015-09-01 Covidien Lp Quick initiation of respiratory support via a ventilator user interface
US8499252B2 (en) 2009-12-18 2013-07-30 Covidien Lp Display of respiratory data graphs on a ventilator graphical user interface
WO2012173120A1 (en) * 2011-06-14 2012-12-20 株式会社東芝 Medical image display device and program
DE102012203288B4 (en) * 2012-03-02 2015-10-01 Siemens Aktiengesellschaft Generation of magnetic resonance-based tomograms
US10362967B2 (en) 2012-07-09 2019-07-30 Covidien Lp Systems and methods for missed breath detection and indication
DE102014211130B4 (en) * 2014-06-11 2016-05-12 Siemens Aktiengesellschaft Automatically determining a slice position for a magnetic resonance examination
US9950129B2 (en) 2014-10-27 2018-04-24 Covidien Lp Ventilation triggering using change-point detection
CN106137242A (en) * 2015-03-25 2016-11-23 上海西门子医疗器械有限公司 A kind of canel barium meal contrast examination exposure method and device
US5431161A (en) * 1993-04-15 1995-07-11 Adac Laboratories Method and apparatus for information acquistion, processing, and display within a medical camera system
DE19529636C2 (en) * 1995-08-11 1997-07-31 Siemens Ag A method for MR imaging of a plurality of layers and the arrangement for implementing the method
DE19846687C2 (en) * 1998-10-09 2001-07-26 Auer Dorothee Surgical auxiliary apparatus for use in performing medical procedures and methods for forming an image in the context of medical procedures
DE19854939C2 (en) * 1998-11-27 2001-11-22 Siemens Ag Method and apparatus for generating CT images
DE10048438A1 (en) * 2000-09-29 2002-04-18 Siemens Ag Reference image display device for assisting in positioning layers for layer measurements has processor that can rotate reference image, layer displays according to user entered commands
2002-05-15 DE DE2002121642 patent/DE10221642B4/en not_active Expired - Fee Related
2003-05-15 CN CN 03131469 patent/CN100556363C/en active IP Right Grant
EP0501993B1 (en) 1997-06-11 Probe-correlated viewing of anatomical image data
DE10311319B4 (en) 2013-02-21 Method, system and computer product for planning a cardiac intervention procedure
US5594849A (en) 1997-01-14 Biomedical magnetism imaging apparatus and method
US5730129A (en) 1998-03-24 Imaging of interventional devices in a non-stationary subject
US7182083B2 (en) 2007-02-27 CT integrated respiratory monitor
US7778686B2 (en) 2010-08-17 Method and apparatus for medical intervention procedure planning and location and navigation of an intervention tool
US6529766B1 (en) 2003-03-04 Method for displaying the tip of a medial instrument situated in the body of a patient
EP1820450B9 (en) 2012-01-11 X-ray diagnostic apparatus, image processing apparatus, and program
US20040034297A1 (en) 2004-02-19 Medical device positioning system and method
US9924887B2 (en) 2018-03-27 Medical image display apparatus
US20080009700A1 (en) 2008-01-10 System and method for interventional procedures using mri
US5671739A (en) 1997-09-30 Imaging of interventional devices during medical procedures
US20020068863A1 (en) 2002-06-06 Method and system for selecting and displaying medical image data
US5287276A (en) 1994-02-15 Localized motion artifact reduction in projection imaging
US6484048B1 (en) 2002-11-19 Real-time interactive three-dimensional locating and displaying system
JP2006512950A (en) 2006-04-20 Method and apparatus for tracking medical instruments
US7454043B2 (en) 2008-11-18 Image processing unit and method of associating stored images with current images
JP4686484B2 (en) 2011-05-25 Spatial roadmap generation method and system for interventional device, and quality control system for monitoring the spatial accuracy
NL1024584C2 (en) 2006-05-29 Method and device for medical intervention procedure planning.
EP2165215B1 (en) 2014-05-07 Image formation apparatus and method for nuclear imaging
CN101686825B (en) 2012-08-22 Adjusting acquisition protocols for dynamic medical imaging using dynamic models
KR100971417B1 (en) 2010-07-21 Ultrasound system for displaying neddle for medical treatment on compound image of ultrasound image and external medical image
US9468412B2 (en) 2016-10-18 System and method for accuracy verification for image based surgical navigation
JP4584553B2 (en) 2010-11-24 An improved method for displaying temporal changes in spatially matched images
US4793357A (en) 1988-12-27 CT blood flow mapping with xenon gas enhancement
2008-10-24 FPAY Renewal fee payment (event date is renewal date of database)
Free format text: PAYMENT UNTIL: 20111024