Skip to content

DIA Windows

tdfpy.DiaWindow dataclass

DiaWindow(
    *,
    window_index: int,
    window_group_id: int,
    scan_num_begin: int,
    scan_num_end: int,
    isolation_mz: float,
    isolation_width: float,
    collision_energy: float,
    frame_id: int,
    rt: float,
    polarity: Polarity | None,
    _timsdata: TimsData = _timsdata_field()
)

Bases: DiaWindowGroup, _MobilityWindow

A DIA isolation window in one specific MS/MS frame.

Extends DiaWindowGroup with the frame it was acquired in, and gives spectrum access and ion-mobility ranges for the window's scan range.

timsdata property

timsdata: TimsData

The reader's open :class:TimsData.

Raises:

Type Description
ReaderClosedError

If the reader that built this element was closed.

scan_num_range property

scan_num_range: tuple[int, int]

(scan_num_begin, scan_num_end), end exclusive.

isolation_mz_range property

isolation_mz_range: tuple[float, float]

Quadrupole isolation window (isolation_mz - width / 2, isolation_mz + width / 2), low first.

ms_level property

ms_level: int

MS level of the window's spectra: always 2 (an MS/MS isolation window).

ook0_range property

ook0_range: tuple[float, float]

(ook0_begin, ook0_end): lowest and highest 1/K0 (V·s/cm²) of the scan range, low first.

ook0_begin property

ook0_begin: float

Lowest 1/K0 (V·s/cm²) of the scan range.

ook0_end property

ook0_end: float

Highest 1/K0 (V·s/cm²) of the scan range.

ccs_range property

ccs_range: tuple[float, float]

(ccs_begin, ccs_end): CCS (Ų) range for charge 1 at isolation_mz, low first.

ccs_begin property

ccs_begin: float

Lowest CCS (Ų) of the scan range, for charge 1 at isolation_mz.

ccs_end property

ccs_end: float

Highest CCS (Ų) of the scan range, for charge 1 at isolation_mz.

voltage_range property

voltage_range: tuple[float, float]

(voltage_begin, voltage_end): TIMS voltage (V) range of the scan range, low first.

voltage_begin property

voltage_begin: float

Lowest TIMS voltage (V) of the scan range.

voltage_end property

voltage_end: float

Highest TIMS voltage (V) of the scan range.

frame_id instance-attribute

frame_id: int

MS/MS frame this window was acquired in.

rt instance-attribute

rt: float

Retention time of that frame in seconds.

polarity instance-attribute

polarity: Polarity | None

"positive" / "negative", None if unknown.

scan_peaks

scan_peaks() -> list[npt.NDArray[np.float64]]

Raw peaks, one (N_i, 2) [m/z, intensity] float64 array per mobility scan.

The list has one entry per scan in this element's scan range, in scan order; empty scans give a (0, 2) array.

Raises:

Type Description
ReaderClosedError

If the reader was closed.

TdfpyError

If a window's scan range does not fit its frame (corrupt file).

Source code in src/tdfpy/elems.py
def scan_peaks(self) -> list[npt.NDArray[np.float64]]:
    """Raw peaks, one ``(N_i, 2)`` ``[m/z, intensity]`` float64 array per mobility scan.

    The list has one entry per scan in this element's scan range, in scan
    order; empty scans give a ``(0, 2)`` array.

    Raises:
        ReaderClosedError: If the reader was closed.
        TdfpyError: If a window's scan range does not fit its frame (corrupt file).
    """
    td = self.timsdata
    bounds = self._scan_bounds()
    begin, end = bounds if bounds is not None else (0, td.frame_metadata(self.frame_id).num_scans)
    arrays = []
    for index_array, int_array in td.read_scans(self.frame_id, begin, end):
        mz_array = td.index_to_mz(self.frame_id, index_array)
        arrays.append(np.stack((mz_array, int_array), axis=-1).astype(np.float64))
    return arrays

raw_peaks

raw_peaks(
    *,
    exclude: ChargeStateRegion | None = None,
    smooth: Smooth | None = None,
    noise: NoiseSpec = None,
    mobility_type: MobilityType = "ook0"
) -> npt.NDArray[np.float64]

Raw peaks as one (N, 3) [m/z, intensity, ion_mobility] array.

Restricted to this element's scan range. See :func:tdfpy.get_raw_peaks for the keyword arguments.

Raises:

Type Description
ReaderClosedError

If the reader was closed.

TdfpyError

If a window's scan range does not fit its frame (corrupt file).

Source code in src/tdfpy/elems.py
def raw_peaks(
    self,
    *,
    exclude: ChargeStateRegion | None = None,
    smooth: Smooth | None = None,
    noise: NoiseSpec = None,
    mobility_type: MobilityType = "ook0",
) -> npt.NDArray[np.float64]:
    """Raw peaks as one ``(N, 3)`` ``[m/z, intensity, ion_mobility]`` array.

    Restricted to this element's scan range. See :func:`tdfpy.get_raw_peaks`
    for the keyword arguments.

    Raises:
        ReaderClosedError: If the reader was closed.
        TdfpyError: If a window's scan range does not fit its frame (corrupt file).
    """
    return get_raw_peaks(
        self.timsdata,
        self.frame_id,
        scan_range=self._scan_bounds(),
        exclude=exclude,
        smooth=smooth,
        noise=noise,
        mobility_type=mobility_type,
    )

centroid

centroid(
    *,
    exclude: ChargeStateRegion | None = None,
    smooth: Smooth | None = None,
    noise: NoiseSpec = None,
    mobility_type: MobilityType = "ook0",
    centroid: Centroider | None = None
) -> npt.NDArray[np.float64]

Centroided peaks as one (N, 3) [m/z, intensity, ion_mobility] array.

Restricted to this element's scan range. The raw-peak keywords are passed to :func:tdfpy.get_raw_peaks; centroider settings live on :class:~tdfpy.Centroider (default :class:~tdfpy.MergePeaksCentroider).

Raises:

Type Description
ReaderClosedError

If the reader was closed.

TdfpyError

If a window's scan range does not fit its frame (corrupt file).

Source code in src/tdfpy/elems.py
def centroid(
    self,
    *,
    exclude: ChargeStateRegion | None = None,
    smooth: Smooth | None = None,
    noise: NoiseSpec = None,
    mobility_type: MobilityType = "ook0",
    centroid: Centroider | None = None,
) -> npt.NDArray[np.float64]:
    """Centroided peaks as one ``(N, 3)`` ``[m/z, intensity, ion_mobility]`` array.

    Restricted to this element's scan range. The raw-peak keywords are
    passed to :func:`tdfpy.get_raw_peaks`; centroider settings live on
    :class:`~tdfpy.Centroider` (default :class:`~tdfpy.MergePeaksCentroider`).

    Raises:
        ReaderClosedError: If the reader was closed.
        TdfpyError: If a window's scan range does not fit its frame (corrupt file).
    """
    return get_centroided_spectrum(
        self.timsdata,
        self.frame_id,
        scan_range=self._scan_bounds(),
        exclude=exclude,
        smooth=smooth,
        noise=noise,
        mobility_type=mobility_type,
        centroid=centroid,
    )

tdfpy.DiaWindowGroup dataclass

DiaWindowGroup(
    *,
    window_index: int,
    window_group_id: int,
    scan_num_begin: int,
    scan_num_end: int,
    isolation_mz: float,
    isolation_width: float,
    collision_energy: float
)

Bases: _IsolationWindow

One window of a DIA window group, shared by every frame that uses the group.

One row of the DiaFrameMsMsWindows table. DiaWindow adds the per-frame fields (frame_id, rt, polarity).

Field Type Description
window_index int 0-based row index in the DiaFrameMsMsWindows table (not per group)
window_group_id int Window group ID (the WindowGroup column)
scan_num_begin int First mobility scan (inclusive)
scan_num_end int Mobility scan range end (exclusive), so the range is [scan_num_begin, scan_num_end)
isolation_mz float Isolation window center m/z
isolation_width float Isolation window width in Th
collision_energy float Collision energy in eV

scan_num_range property

scan_num_range: tuple[int, int]

(scan_num_begin, scan_num_end), end exclusive.

isolation_mz_range property

isolation_mz_range: tuple[float, float]

Quadrupole isolation window (isolation_mz - width / 2, isolation_mz + width / 2), low first.