Skip to content

Unable to read Bruker 2D ser file if half or less slices were recorded #237

@FlorianSchreiner1

Description

@FlorianSchreiner1

When trying to read the Bruker raw data of an unfinished or prematurely stopped 2D experiment with half or fewer slices acquired, ng.bruker.read() fails to correctly guess the shape of the data. As far as I have been able to pinpoint the issue, it seems like ng.bruker.guess_shape() introduces it.

As an example lets take a 2D acquisition dataset with 1024 points in the direct dimension and 8 slices in the indirect dimension. guess_shape() would correctly calculate the shape as [0, 0, 8, 1024] in line 1060 or 1062 depending on the spectrometer used.
If only 4 slices in the indirect dimension were acquired, this calculation would again yield the correct shape of [0, 0, 4, 1024]. The problem will then be introduced in lines 1066 and 1067 of nmrglue/fileio/bruker.py while trying to interpret the residual file size to [1, 2, 4, 1024]. As far as I can tell, this problem occurs since TopSpin saves the raw data files with the intended size, not the actual size of the acquired data.

Additionally, lines 1066 and 1067 do not account for DTYPA, so if the example above is calculated for a NEO type spectrometer the resulting shape would be [1, 4, 4, 1024]. This behavior also results in ng.bruker.read() not being able to correctly read 2D data from NEO type spectrometers in general, since guess_shape() will always assume a third dimension (with the example above [1, 2, 8, 1024] if all slices were acquired).

I think the best way to handle this would be to first include DTYPA in lines 1066 and 1067 and only include dimensions for which a corresponding acquisition dictionary was found. The potentially missing slices could then be extrapolated via the file size.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions