Skip to content

Improvement Proposal over bvbabel APIs #75

@ChengranAA

Description

@ChengranAA

Dear Faruk,

I have a proposed improvement over general API calls.

I implemented a higher abstraction layer that allows bvbabel to read typed objects rather than named dictionaries and numpy arrays, which also does not break the original dependency since it relies only on Python built-in features.

This way it lets users take advantage of IDE syntax suggesting for easy access to fields.

Example change like this:

https://github.com/ChengranAA/bvbabel/blob/main/bvbabel/vmr.py

And code for reading a VMR file will be like this:

from bvbabel.vmr import VMR

vmr = VMR.read("example.vmr")
print(vmr.dim_x, vmr.data.shape)
vmr.write("output.vmr")

# header-only (skip voxel data)
header = VMR.read("example.vmr", load_data=False)
print(header.data)  # None

And this does not break the original APIs:

header, data = bvbabel.vmr.read_vmr("subject.vmr")
bvbabel.vmr.write_vmr("output.vmr", header, data)

Regarding issue #21, the data attribute can be skipped by providing the read method with load_data=False.

Currently it's only proof of concept. Let me know your thoughts!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions