protocol_manager.api.mri_sequence_api#

MRI sequence endpoints.

Attributes#

Functions#

mri_sequence_form(, description, sequence_type, tags)

Convert form data to BaseMRISequence model.

get_mri_sequence_by_id(...)

Retrieve an MRI sequence by its ID.

create_mri_sequence([seq_file, xml_file, ...])

Upload an MRI sequence file and store it with the provided metadata.

get_all_mri_sequences([database])

Retrieve a list of all MRI sequences from the database.

get_mri_sequence_file_by_id(sequence_id, background_tasks)

Retrieve an MRI sequence file by its ID.

get_mri_sequence_header_file_by_id(sequence_id, ...[, ...])

Retrieve an MRI sequence header (ISMRMRD header) file by its ID.

update_mri_sequence_endpoint(sequence_id, sequence_meta)

Update an MRI sequence with new data.

delete_mri_sequence_endpoint() → None)

Delete an MRI sequence by its ID.

Module Contents#

protocol_manager.api.mri_sequence_api.seq_router#
async protocol_manager.api.mri_sequence_api.mri_sequence_form(name: str = Form(...), description: str = Form(''), sequence_type: str = Form(''), tags: list[str] = Form([])) → scanhub_libraries.models.BaseMRISequence#

Convert form data to BaseMRISequence model.

Parameters:
  • name (str) – The name of the MRI sequence.

  • description (str | None) – A description of the MRI sequence.

  • sequence_type (str | None) – The type of the MRI sequence (e.g., “imaging”, “calibration”, etc.).

  • tags (list[str]) – A list of tags associated with the MRI sequence.

async protocol_manager.api.mri_sequence_api.get_mri_sequence_by_id(sequence_id: str, database=Depends(get_mongo_database)) → scanhub_libraries.models.MRISequenceOut#

Retrieve an MRI sequence by its ID.

Parameters:
  • sequence_id (str) – The ID of the MRI sequence to retrieve.

  • database (AsyncIOMotorDatabase) – The MongoDB database handle.

Returns:

The retrieved MRI sequence.

Return type:

MRISequence

async protocol_manager.api.mri_sequence_api.create_mri_sequence(seq_file: fastapi.UploadFile = File(...), xml_file: fastapi.UploadFile = File(...), sequence_meta: scanhub_libraries.models.BaseMRISequence = Depends(mri_sequence_form), database=Depends(get_mongo_database))#

Upload an MRI sequence file and store it with the provided metadata.

Parameters:
  • mri_sequence (MRISequenceCreate) – The MRI sequence metadata.

  • seq_file (UploadFile) – The MRI sequence file to store.

  • xml_file (UploadFile) – The ISMRMRD header xml file to store.

  • database (AsyncIOMotorDatabase) – The MongoDB database handle.

Returns:

The stored MRI sequence with the uploaded file.

Return type:

MRISequence

async protocol_manager.api.mri_sequence_api.get_all_mri_sequences(database=Depends(get_mongo_database))#

Retrieve a list of all MRI sequences from the database.

Parameters:

database (AsyncIOMotorDatabase) – The MongoDB database handle.

Returns:

The list of MRI sequences.

Return type:

List[MRISequence]

async protocol_manager.api.mri_sequence_api.get_mri_sequence_file_by_id(sequence_id: str, background_tasks: fastapi.BackgroundTasks, name: str = 'sequence', database=Depends(get_mongo_database))#

Retrieve an MRI sequence file by its ID.

Parameters:
  • sequence_id (str) – The ID of the MRI sequence to retrieve.

  • background_tasks (BackgroundTasks) – The background tasks to run.

  • name (str) – The name of the file to download.

  • database (AsyncIOMotorDatabase) – The MongoDB database handle.

Returns:

The retrieved MRI sequence file.

Return type:

FileResponse

async protocol_manager.api.mri_sequence_api.get_mri_sequence_header_file_by_id(sequence_id: str, background_tasks: fastapi.BackgroundTasks, name: str = 'header', database=Depends(get_mongo_database))#

Retrieve an MRI sequence header (ISMRMRD header) file by its ID.

Parameters:
  • sequence_id (str) – The ID of the MRI sequence to retrieve.

  • background_tasks (BackgroundTasks) – The background tasks to run.

  • name (str) – The name of the file to download.

  • database (AsyncIOMotorDatabase) – The MongoDB database handle.

Returns:

The retrieved MRI sequence file.

Return type:

FileResponse

async protocol_manager.api.mri_sequence_api.update_mri_sequence_endpoint(sequence_id: str, sequence_meta: scanhub_libraries.models.BaseMRISequence, database=Depends(get_mongo_database))#

Update an MRI sequence with new data.

Parameters:
  • sequence_id (str) – The ID of the MRI sequence to update.

  • mri_sequence (MRISequence) – The updated MRI sequence data.

  • database (AsyncIOMotorDatabase) – The MongoDB database handle.

Returns:

The updated MRI sequence.

Return type:

MRISequence

async protocol_manager.api.mri_sequence_api.delete_mri_sequence_endpoint(sequence_id: str, database=Depends(get_mongo_database)) → None#

Delete an MRI sequence by its ID.

Parameters:
  • sequence_id (str) – The ID of the MRI sequence to delete.

  • database (AsyncIOMotorDatabase) – The MongoDB database handle.

Return type:

None