Skip to content

XNAT Integration #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SachidanandAlle opened this issue Jul 26, 2021 · 26 comments
Closed

XNAT Integration #223

SachidanandAlle opened this issue Jul 26, 2021 · 26 comments
Labels
backlog Items to be decided in the future when/if to implement

Comments

@SachidanandAlle
Copy link
Collaborator

Integrate monai label server with XNAT

@SachidanandAlle SachidanandAlle added the backlog Items to be decided in the future when/if to implement label Jul 26, 2021
@hshuaib90
Copy link

I would be very keen to have this integration working. Do we know if there are particular hurdles or challenges with XNAT integration?

@SachidanandAlle
Copy link
Collaborator Author

We need some xnat community to help on developing this plugin.. otherwise MONAILabel server has all the rest apis (ingredients) to support any viewers.. we took an extra step of providing such 2 reference implementations (3Dslicer and vanilla OHIF) to showcase the same.. these python/js based examples should be enough for others to follow.

@diazandr3s
Copy link
Collaborator

I would be very keen to have this integration working. Do we know if there are particular hurdles or challenges with XNAT integration?

This will be a great use case, @hshuaib90. MONAI Label + OHIF + XNAT
Happy to chat more about this. As @SachidanandAlle said, MONAI Label is ready to be integrated with XNAT. It has DICOMWeb support and there are several apps that can be used to facilitate medical image annotation.
There is also interest in supporting the new OHIF v3. See here #603

@hshuaib90
Copy link

We have XNAT server set up at my hospital and I'd be happy to support early testing. I'm afraid I don't know XNAT well enough to contribute to the development - at least not yet.

@diazandr3s
Copy link
Collaborator

Thanks, @hshuaib90. This is a great idea.
Pinging @mjorgecardoso who can also contribute to this conversation :)

@pwrightkcl
Copy link
Contributor

I have got MONAI label running at KCH, using the DGX as server and data store, and a standard NHS PC with Slicer as client. Long term, I expect we will want to use XNAT and OHIF too.

@SachidanandAlle
Copy link
Collaborator Author

I have got MONAI label running at KCH, using the DGX as server and data store, and a standard NHS PC with Slicer as client. Long term, I expect we will want to use XNAT and OHIF too.

That's good.. lets c on XNAT+OHIF if something can happen in near future.. MONAILabel is an opensource project.. so lets hope to get some more developers from XNAT community pitching in to develop the required plugin at XNAT side to interact with MONAI Label server.

@pwrightkcl
Copy link
Contributor

I understand the current implementation is to use DICOM web. How does that handle labels?

  1. How do you feed it existing labels?
  2. Where does it put labels that you submit?

@SachidanandAlle
Copy link
Collaborator Author

DICOM Seg is created and pushed via DICOM Web server (given all permissions are there to read/write for MONAILabel server)

@jamesobutler
Copy link
Contributor

jamesobutler commented Apr 3, 2022

For some additional knowledge on this topic, 3D Slicer + XNAT has existed with https://github.com/NrgXnat/XNATSlicer however it had become unmaintained and was recently disabled from the Slicer extensions catalog after some cleaning up of old extensions in preparation for the Slicer 5.0 release. It could be enabled again if there are developers interested in supporting it again. See https://github.com/Slicer/ExtensionsIndex/blob/master/ARCHIVE/XNATSlicer.s4ext

Update: It has been reenabled https://github.com/Slicer/ExtensionsIndex/blob/5f5ac42bab1ca7b57f25b78b12d39a4c6d9cc1ee/XNATSlicer.s4ext

@DrRadiohead2
Copy link

DrRadiohead2 commented May 20, 2022

Hi.
We have xnat ml set up on aws. We were confused about deploying AIAA Or using monai label. Monai label looks more promising however needs more clarity about how data is trained which more straightforward in XNAT ML. We are more interested in inference tools. Can you please guide us how to deploy inference tool.

Regards
Dr Akshaykumar

@diazandr3s
Copy link
Collaborator

Hi @DrAkshaykumar,

Thanks for your comment.

MONAI Label / XNAT integration is in the roadmap. This integration will allow both inference and training and user authentication should permit specific users to trigger training.

Are you using the DICOM Web protocol? or do you fetch images from XNAT directly when using AIAA?

@DrRadiohead2
Copy link

DrRadiohead2 commented May 23, 2022 via email

@amrshadid
Copy link

Any update ?

@DrRadiohead2
Copy link

DrRadiohead2 commented Oct 19, 2022 via email

@SachidanandAlle
Copy link
Collaborator Author

Some of the development and integration is completed on XNAT side.
And there must be an early version of the plugin available.
https://wiki.xnat.org/documentation/xnat-ohif-viewer/release-notes-126157097.html

Please follow more on the XNAT development forum.

@diazandr3s
Copy link
Collaborator

Some of the development and integration is completed on XNAT side. And there must be an early version of the plugin available. https://wiki.xnat.org/documentation/xnat-ohif-viewer/release-notes-126157097.html

Please follow more on the XNAT development forum.

@danieltudosiu

@DrRadiohead2
Copy link

Hi,
We are trying to integrate XNAT with monai label, so that the models can be trained and deployed in the same pipeline.
Can someone please prepare a detailed step by step guide to help us integrate it.
We have currently hosted XNAT on AWS. @diazandr3s please discuss in meeting next year.
Regards

@danieltudosiu
Copy link
Contributor

Hi @DrAkshaykumar,

If it is ok with you I will join as well the meeting as I am working closely with @diazandr3s and MONAI Label's integration with XNAT is party of my PostDoc's JD.

I think I will be one of the main points of contact on this issue in the next year.

Best regards,

Dan

@SachidanandAlle
Copy link
Collaborator Author

Adding @AHarouni who has helped and lead this xnat + monailabel integration in many ways

@AHarouni
Copy link
Collaborator

Hi All

Currently the xnat datastore in monai label along with xnat=ohif viewer V3.4 enables the user to run inference of images in the project very efficiently as monai label can directly access xnat data.
I did send code to xnat-ohif developer to allowing saving of dicom seg back to xnat. once this code is merged you would be able to run batch inference from monai-label api to run inference on all patients in a project convert o dicom seg and push this segmentation to xnat so user can load this seg
Another addition that might be useful is using Rapid reader in xnat. This is unrelated to monai label but you can create a new worklist of all the patients which just finished batch infer for a quick way for radiologist to review and add comments to the quality of the AI.

There is a minor issue of unifying the AI dicom seg name and who user can name the dicom seg they create so monai-label + xnat datastore can figure out what is unlabeled vs labeled by a radiologist vs labeled by the batch infer. One issue here is each series can have multiple annotations one for liver tumor, kidney tumor etc

For end to end you should be able to use the xnat jupyter hub feature to launch monai jupyter container where you have access to the data of a given project. I successfully integrated this after modifying monai container and adhere to Xnat jupyter expectations

Open items I have on my list:

  • Moving series selector logic from monia deploy to either monai label or monai core. This will allow you to reject series that don't match your dicom tags criteria as running only on modality = CT etc
  • Utilize xnat-ohif new measurements feature by creating measurements on the center slice where the tumor / organ exist. This requires a new transformation to locate the organ / tumor central slice get teh UUID of that slice and create the measurements object expected by Xnat.
  • Creating a pdf report with findings and pushing it back to xnat ohif. This is a big item with multiple blocker. first xnat-ohif doesn't yet support showing encapsulated pdf. Need a new monai transform to calculate organ/ tumorsize and place them nicely in a report. Need to include key image of coronal/sagital /axial of the tumor.

Hope that helps clarifies current status and next steps.

1 similar comment
@AHarouni
Copy link
Collaborator

Hi All

Currently the xnat datastore in monai label along with xnat=ohif viewer V3.4 enables the user to run inference of images in the project very efficiently as monai label can directly access xnat data.
I did send code to xnat-ohif developer to allowing saving of dicom seg back to xnat. once this code is merged you would be able to run batch inference from monai-label api to run inference on all patients in a project convert o dicom seg and push this segmentation to xnat so user can load this seg
Another addition that might be useful is using Rapid reader in xnat. This is unrelated to monai label but you can create a new worklist of all the patients which just finished batch infer for a quick way for radiologist to review and add comments to the quality of the AI.

There is a minor issue of unifying the AI dicom seg name and who user can name the dicom seg they create so monai-label + xnat datastore can figure out what is unlabeled vs labeled by a radiologist vs labeled by the batch infer. One issue here is each series can have multiple annotations one for liver tumor, kidney tumor etc

For end to end you should be able to use the xnat jupyter hub feature to launch monai jupyter container where you have access to the data of a given project. I successfully integrated this after modifying monai container and adhere to Xnat jupyter expectations

Open items I have on my list:

  • Moving series selector logic from monia deploy to either monai label or monai core. This will allow you to reject series that don't match your dicom tags criteria as running only on modality = CT etc
  • Utilize xnat-ohif new measurements feature by creating measurements on the center slice where the tumor / organ exist. This requires a new transformation to locate the organ / tumor central slice get teh UUID of that slice and create the measurements object expected by Xnat.
  • Creating a pdf report with findings and pushing it back to xnat ohif. This is a big item with multiple blocker. first xnat-ohif doesn't yet support showing encapsulated pdf. Need a new monai transform to calculate organ/ tumorsize and place them nicely in a report. Need to include key image of coronal/sagital /axial of the tumor.

Hope that helps clarifies current status and next steps.

@mariamonzon
Copy link

is there any up to guide/tutorial/example on how to implement monai label with XNAT?

@AHarouni
Copy link
Collaborator

Hi @mariamonzon
It seems like that part of the documentation was moved. I will try to help you out, please try to follow steps below

  1. Install xnat by following their documentation. You can simply use their docker compose to bring it up quickly
    i . Verify you have oxnat ohif working by downloading jar file for ohif plugin for xnat and place it in the plugin folder.
    ii. you need to restart xnat for changes to work
  2. Verify that you monai label can start normally with local file system.
  3. use below commands before starting monai label
export MONAI_LABEL_DATASTORE=xnat
export MONAI_LABEL_DATASTORE_USERNAME=admin  -->replace it if you changed the user 
export MONAI_LABEL_DATASTORE_PASSWORD=admin  -->replace it if you changed the default password 
export MONAI_LABEL_DATASTORE_ASSET_PATH=   --> place the path to the xnat data folder, so monai label can simply use that path to resolve images, other wise monai label will download data from xnat using http calls 
export MONAI_LABEL_DATASTORE_PROJECT=  --> if you want to restrict it to one folder 
export MONAI_LABEL_DATASTORE_CACHE_PATH=  --> assuming you are not sharing the same file system if you need to cache 
export MONAI_LABEL_DICOMWEB_CONVERT_TO_NIFTI=false
monailabel start_server --app apps/radiology --studies http://<xnat_ip>:80 --conf models segmentation_spleen
  1. verify monai label starts and the logs show it logged into xnat correctly
  2. now you need to configure xnat ohif to see monai label
USER_PASS="admin:admin"
AIAASERVERPORT="http://<monallabel_ip>:8000"
ROOTURL="xnat_ip:80"
!curl -u $USER_PASS -X PUT "$ROOTURL/xapi/ohifaiaa/servers" \
        -H "accept: */*" -H "Content-Type: application/json" \
        -d "[ \"$AIAASERVERPORT\"]"
  1. configure ohif UI
    i . now go to a patient, open it in ohif,
    ii. go to preference, experimental, check monai label.
    iii. click masks from the tool bar, you should see a new icon called monai label
  2. in ohif click the right panel "masks" you should see a panel form moanai label and your model should show up there

Above steps enable the manual triggering of model inference, I have been working on automatically trigger inference once a new study is receiver by xnat.

Hope that helps.
let me know if you face issues

@mrjamesdickson
Copy link

@AHarouni 'I have been working on automatically trigger inference once a new study is receiver by xnat.' Did you ever get that piece working?

@AHarouni
Copy link
Collaborator

AHarouni commented Feb 10, 2025

Hi @mrjamesdickson
Yes I managed to get that workflow. Can you please open an issue for this and assign it to me so I can add this feature to monai label. This workflow required multiple changes:
1- Creating a command for xnat using the container service.
2- Modifying the batch infer code on monai label
3- Changing you app to use the new batch infer code
4- Setting up Xnat to auto trigger the workflow.

I moved the details to this wiki page so others can find it easily https://github.com/Project-MONAI/MONAILabel/wiki/Deployment-Setup-in-a-Hospital-setting-using-Xnat-and-Monai-label

Hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Items to be decided in the future when/if to implement
Projects
None yet
Development

No branches or pull requests