imaging_api.routers.projects ============================ .. py:module:: imaging_api.routers.projects Attributes ---------- .. autoapisummary:: imaging_api.routers.projects.router imaging_api.routers.projects.XNATAuthHeaders Functions --------- .. autoapisummary:: imaging_api.routers.projects.get_projects imaging_api.routers.projects.create_project_endpoint imaging_api.routers.projects.create_project_from_central_hub_project imaging_api.routers.projects.delete_project_endpoint imaging_api.routers.projects.get_project_endpoint imaging_api.routers.projects.get_project_subjects_endpoint imaging_api.routers.projects.get_project_experiments_endpoint imaging_api.routers.projects.get_project_experiment_endpoint Module Contents --------------- .. py:data:: router .. py:data:: XNATAuthHeaders .. py:function:: get_projects(headers: XNATAuthHeaders) -> list[imaging_api.routers.schemas.Project] Retrieves a list of all projects in XNAT. :param headers: XNAT authentication headers. :type headers: XNATAuthHeaders :returns: List of projects in XNAT. :rtype: list[imaging_api.routers.schemas.Project] :raises HTTPException: If there is an error during the retrieval of projects. .. py:function:: create_project_endpoint(project_id: str, project_secondary_id: str, project_name: str, *, project_description: str = '', headers: XNATAuthHeaders) -> imaging_api.routers.schemas.Project Creates a new project in XNAT. :param project_id: Unique identifier for the project. :type project_id: str :param project_secondary_id: Secondary identifier for the project. :type project_secondary_id: str :param project_name: Name of the project. :type project_name: str :param project_description: Description of the project. :type project_description: str, optional :param headers: XNAT authentication headers. :type headers: XNATAuthHeaders :returns: The created project object. :rtype: imaging_api.routers.schemas.Project :raises HTTPException: If there is an error during the creation of the project. .. py:function:: create_project_from_central_hub_project(central_hub_project: imaging_api.routers.schemas.CentralHubProject, headers: XNATAuthHeaders, background_tasks: fastapi.BackgroundTasks) -> imaging_api.routers.schemas.CreatedProject :async: Creates a new project in XNAT based on Central Hub project information. Central Hub project information includes the project ID, project name, and users. A dedicated XNAT project ID will be created, as well as corresponding users. If users already exist on XNAT with those emails, they will be added to the project. If users do not exist on XNAT, they will be created and added to the project. :param central_hub_project: Central Hub project object including its :type central_hub_project: imaging_api.routers.schemas.CentralHubProject :param ID: :param name: :param and users.: :param headers: XNAT authentication headers. :type headers: XNATAuthHeaders :param background_tasks: Background task manager for retrieval scheduling. :type background_tasks: BackgroundTasks :returns: The created project object. :rtype: CreatedProject (imaging_api.routers.schemas.CreatedProject) :raises HTTPException: If there is an error during the creation of the project. .. py:function:: delete_project_endpoint(project_id: str, headers: XNATAuthHeaders) -> imaging_api.routers.schemas.Project :async: Deletes an existing project in XNAT. :param project_id: Unique identifier for the project. :type project_id: str :param headers: XNAT authentication headers. :type headers: XNATAuthHeaders :returns: The deleted project object. :rtype: Project :raises HTTPException: If there is an error during the deletion of the project. .. py:function:: get_project_endpoint(project_id: str, headers: XNATAuthHeaders) -> imaging_api.routers.schemas.Project Retrieves details of a specific project in XNAT. The reason we are not using the specific XNAT endpoint ``GET /data/projects/{id}`` is because it returns something like the below, which I am not sure is very useful, is missing fields like ``pi_firstname``, ``pi_lastname``, ``URI`` which we may want to retrieve. .. code-block:: json { "project": { "items": [ { "children": [], "meta": { "create_event_id": 270, "xsi:type": "xnat:projectData", "isHistory": false, "start_date": "Mon Mar 24 18:21:46 UTC 2025" }, "data_fields": { "secondary_ID": "dc5c1758-1a4d-4fca-80ce-fa208d11874d", "name": "string:3fa85f64-5717-4562-b3fc-2c963f66afa6-FL-Project", "description": "Project corresponding to central hub project 3fa85f64-5717-4562-b3fc-2c963f66afa6", "active": "true", "ID": "dc5c1758-1a4d-4fca-80ce-fa208d11874d" } } ] } } :param project_id: Unique identifier for the project. :type project_id: str :param headers: XNAT authentication headers. :type headers: XNATAuthHeaders :returns: The project object. :rtype: Project :raises HTTPException: If there is an error during the retrieval of the project. .. py:function:: get_project_subjects_endpoint(project_id: str, headers: XNATAuthHeaders) -> list[imaging_api.routers.schemas.Subject] Retrieves a list of subjects in a specific project in XNAT. :param project_id: Unique identifier for the project. :type project_id: str :param headers: XNAT authentication headers. :type headers: XNATAuthHeaders :returns: List of subjects in the project. :rtype: list[Subject] :raises HTTPException: If there is an error during the retrieval of subjects for the project. .. py:function:: get_project_experiments_endpoint(project_id: str, headers: XNATAuthHeaders) -> list[imaging_api.routers.schemas.Experiment] Retrieves a list of experiments in a specific project in XNAT. :param project_id: Unique identifier for the project. :type project_id: str :param headers: XNAT authentication headers. :type headers: XNATAuthHeaders :returns: List of experiments in the project. :rtype: list[Experiment] :raises HTTPException: If there is an error during the retrieval of experiments for the project. .. py:function:: get_project_experiment_endpoint(project_id: str, experiment_id_or_label: str, headers: XNATAuthHeaders) -> dict Retrieves details of a specific experiment in a project in XNAT. :param project_id: Unique identifier for the project. :type project_id: str :param experiment_id_or_label: Unique identifier for the experiment. :type experiment_id_or_label: str :param headers: XNAT authentication headers. :type headers: XNATAuthHeaders :returns: The experiment object. :rtype: dict :raises HTTPException: If there is an error during the retrieval of the experiment.