Sequence Management

list

Retrieves a list of sequences in the project. To handle a large number of sequences, they are returned in pages (defaults to 100 sequences per page). Page cursors are provided in the results list to easily navigate to the next or previous page.

Parameters

NameTypeDescription
paginationdictA dictionary containing the limit of the number of assets to be returned in each page (defaults to 100), and the page cursor for page selection (defaults to the first page)
filtersdictA dictionary containing the filters of the assets to be returned.

Return

A msgspec struct of pagination response with the following structure:

PaginationResponse(
    next_page='T2YAGDY1NWFlNDcyMzZkiMDYwMTQ5N2U2',
    prev_page=None,
    data=[
        Sequence(
            id="seq_f77a1a3d-2ea2-45fc-a3f5-dc916a56f28c",
            name="Patient A",
            project_id="proj_cd067221d5a6e4007ccbb4afb5966535",
            items=[
                SequenceEntryAsset(
                    asset_id="asset_b5dff11f-6f70-4642-a85b-56f6f6922ac1",
                    ord=3,
                    role="Sagittal"
                ),
                SequenceEntryAsset(
                    asset_id="asset_fe8ca0ce-654e-4f33-929c-09aa9243850f",
                    ord=6,
                    role="Sagittal"
                ),
            ],
            attributes=SequenceAttributes(
                bytes_used=20,
                bytes_total=1048576,
                items={
                    "report0": "...",
                    "report1": "...",
                }
            ),
            create_date=1705475663570,
            update_date=1705475727051
        )
    ]
)

Examples

from datature.nexus import Client

project = Client("5aa41e8ba........").get_project("proj_b705a........")

project.sequences.list()

# or
project.sequences.list(
    nexus.ApiTypes.Pagination(
        limit= 2,
        page="ZjYzYmJkM2FjN2UxOTA4ZmU0ZjE0Yjk5Mg"
    ),
)

get

Retrieves a sequence by its sequence ID.

Parameters

NameTypeDescription
sequence_idstrThe sequence ID (prefixed with seq_)

Return

A msgspec struct containing the metadata of a sequence with the following structure:

Sequence(
    id="seq_f77a1a3d-2ea2-45fc-a3f5-dc916a56f28c",
    name="Patient A",
    project_id="proj_cd067221d5a6e4007ccbb4afb5966535",
    items=[
        SequenceEntryAsset(
            asset_id="asset_b5dff11f-6f70-4642-a85b-56f6f6922ac1",
            ord=3,
            role="Sagittal"
        ),
        SequenceEntryAsset(
            asset_id="asset_fe8ca0ce-654e-4f33-929c-09aa9243850f",
            ord=6,
            role="Sagittal"
        ),
    ],
    attributes=SequenceAttributes(
        bytes_used=20,
        bytes_total=1048576,
        items={
            "report0": "...",
            "report1": "...",
        }
    ),
    create_date=1705475663570,
    update_date=1705475727051
)

Examples

from datature.nexus import Client

project = Client("5aa41e8ba........").get_project("proj_b705a........")
sequence = project.sequences.get("seq_f77a1a3d-2ea2-45fc-a3f5-dc916a56f28c")

bulk_update

Perform bulk actions for sequence updates. The valid actions include:

  • Linking assets within a sequence
  • Unlinking assets from a sequence
  • Patching the name or attributes of a sequence
  • Deleting an entire sequence

Check out the actions object to learn more about how to specify fields for specific action

Parameters

NameTypeDescription
actionslist[dict]A list of dictionaries containing the metadata of the actions to be taken.
abort_modestrEnum string of handling aborts of the bulk update operation.

SequenceBulkUpdateAbortMode.ABORT_ON_ANY_FAILED: Bulk update operation will be aborted if any single sequence-related action fails.
SequenceBulkUpdateAbortMode.NONE: Bulk update operation will never be aborted even with failed actions.

Return

A msgspec struct containing the result status of each individual action:

SequenceBulkUpdateResults(
    actions=[
        <SequenceBulkUpdateResult.OK: 'Ok'>,
        <SequenceBulkUpdateResult.FAILED_LINK_ASSET_NOT_FOUND: 'FailedLinkAssetNotFound'>,
        <SequenceBulkUpdateResult.OK: 'Ok'>,
    ]
)

Examples

  • Linking new assets to a sequence using the asset IDs and patching the sequence attributes:
from datature.nexus import Client

project = Client("5aa41e8ba........").get_project("proj_b705a........")

project.sequences.bulk_update(
    actions=[
        # links the `image_1.jpg` asset to a sequence named `Patient A` 
        {
            "sequence": {
                "name": "Patient A",
                "role": "Sagittal",
                "ord": 1,
            },
            "asset_filename": "image_1.jpg",
        },
        # links the `image_2.jpg` asset to a sequence named `Patient A`
        {
            "sequence": {
                "name": "Patient A",
                "role": "Sagittal",
                "ord": 2,
            },
            "asset_filename": "image_2.jpg",
        },
        # patches the sequence
        {
            "patch": {
                "attributes": {
                    "age": 20,
                    "gender": "male",
                    "height": 180,
                    "weight": 70,
                },
            },
            "sequence_name": "Patient B",
        },
    ]
)
  • Unlinking an asset from a sequence using the asset filename:
from datature.nexus import Client

project = Client("5aa41e8ba........").get_project("proj_b705a........")

project.sequences.bulk_update(
    actions=[
        {
            "asset_filename": "image_1.jpg",
        },
    ]
)
  • Removing a sequence using the sequence ID:
from datature.nexus import Client

project = Client("5aa41e8ba........").get_project("proj_b705a........")

project.sequences.bulk_update(
    actions=[
        {
            "sequence_id": "seq_f77a1a3d-2ea2-45fc-a3f5-dc916a56f28c",
        },
    ]
)


patch

Patches the name or the attributes contained within a sequence.

Parameters

NameTypeDescription
sequence_idstrThe sequence ID.
patchdictA dictionary containing the metadata to patch the sequence with.

Return

A msgspec struct of pagination response with the following structure:

Sequence(
    id="seq_f77a1a3d-2ea2-45fc-a3f5-dc916a56f28c",
    name="Patient A",
    project_id="proj_cd067221d5a6e4007ccbb4afb5966535",
    items=[
        SequenceEntryAsset(
            asset_id="asset_b5dff11f-6f70-4642-a85b-56f6f6922ac1",
            ord=3,
            role="Sagittal"
        ),
        SequenceEntryAsset(
            asset_id="asset_fe8ca0ce-654e-4f33-929c-09aa9243850f",
            ord=6,
            role="Sagittal"
        ),
    ],
    attributes=SequenceAttributes(
        bytes_used=20,
        bytes_total=1048576,
        items={
            "report0": "...",
            "report1": "...",
        }
    ),
    create_date=1705475663570,
    update_date=1705475727051
)

Examples

from datature.nexus import Client

project = Client("5aa41e8ba........").get_project("proj_b705a........")

project.sequences.patch(
    "seq_f77a1a3d-2ea2-45fc-a3f5-dc916a56f28c",
    {
        "name": "Patient A",
        "attributes": {
            "age": 20,
            "gender": "male",
            "height": 180,
            "weight": 70,
        },
    }
)

delete

Deletes a sequence from the project.

❗️

Deleting a sequence is irreversible. This will unlink all assets that were originally within that sequence, and remove all sequence attributes from that sequence.

Parameters

NameTypeDescription
sequence_idstrThe sequence ID.

Return

A msgspec struct of pagination response with the following structure:

DeleteResponse(
    deleted=True,
    id='seq_f77a1a3d-2ea2-45fc-a3f5-dc916a56f28c'
)

Examples

from datature.nexus import Client

project = Client("5aa41e8ba........").get_project("proj_b705a........")

project.sequences.delete("seq_f77a1a3d-2ea2-45fc-a3f5-dc916a56f28c")