Modality = Opthalmic Photography; Error on image upload

184 views
Skip to first unread message

Choon Hua Thng

unread,
Mar 4, 2025, 9:42:02 PM3/4/25
to xnat_discussion
I added a new data type for xnat:opSessionData and xnat:opScanData.

When i uploaded an image via compressed uploader, i get the following error:

org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.

May I know how to rectify the error pls ?

Timothy Olsen

unread,
Mar 4, 2025, 9:46:25 PM3/4/25
to xnat_di...@googlegroups.com
Are you uploading DICOM data?
Tim

--
You received this message because you are subscribed to the Google Groups "xnat_discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/xnat_discussion/c437ed68-ec53-4759-8272-4c742ca8ad6fn%40googlegroups.com.

Choon Hua Thng

unread,
Mar 4, 2025, 10:34:55 PM3/4/25
to xnat_di...@googlegroups.com
Yes. Modality = OP


From: xnat_di...@googlegroups.com <xnat_di...@googlegroups.com> on behalf of Timothy Olsen <t...@xnatworks.io>
Sent: Wednesday, March 5, 2025 10:46:08 AM
To: xnat_di...@googlegroups.com <xnat_di...@googlegroups.com>
Subject: Re: [XNAT Discussion] Modality = Opthalmic Photography; Error on image upload
 

Simon Doran

unread,
Mar 5, 2025, 5:43:27 AM3/5/25
to xnat_discussion
Hi Choon,

  I might be off-track here, but based on previous experience, I would say that the next place to look is in the /data/xnat/prearchive directory.

  I'm going to illustrate this with an example of another slightly less common modality that we've been working with, which is Slide Microscopy (SM). I have sent the files to XNAT for a session called dicom_upload and XNAT's session builder has run. (Depending on your settings, this either runs automatically, or you have to manually click on the "Rebuild" button in the prearchive).  The session is currently in the prearchive, associated with the project MICROSCOPY_DEV.

prearchive_example.png
  I'm guessing that in your case, this shows an error in the status column, rather than Ready.

  If I look at the prearchive directory on the backend XNAT server for the project MICROSCOPY_DEV, then I see this:

xnat@xnatdev2204:~$ ls /data/xnat/prearchive/MICROSCOPY_DEV

20240910_170828281

  You can see that the upload is sitting in a time-stamped directory whose name shows you when those data were first received and processed by XNAT and you should easily be able to identify the directory that corresponds to the data that you are looking at. You will see that this matches the upload date in the prearchive page of the user interface.

  If I list the contents of this directory, then I see this:

xnat@xnatdev2204:~$ ls /data/xnat/prearchive/MICROSCOPY_DEV/20240910_170828281

dicom_upload  dicom_upload.xml

Notice that the result of the "Rebuild" operation is present in dicom_upload.xml. It should have non-zero length, because it should contain a session XML. You will recognise this because it has the same form as what pops up when use the View -> XML option in the Actions box on the session page. This is what I get:

ls -l /data/xnat/prearchive/MICROSCOPY_DEV/20240910_170828281/dicom_upload.xml

-rw-r----- 1 xnat xnat 1491 Sep 10 18:13 /data/xnat/prearchive/MICROSCOPY_DEV/20240910_170828281/dicom_upload.xml

xnat@xnatdev2204:~$ cat /data/xnat/prearchive/MICROSCOPY_DEV/20240910_170828281/dicom_upload.xml

<?xml version="1.0" encoding="UTF-8"?>

<xnat:SMSession ID="" UID="1.3.6.1.4.1.36533.8414610519336128691421468925512815321123615" label="dicom_upload" modality="SM" project="MICROSCOPY_DEV" xmlns:arc="http://nrg.wustl.edu/arc" xmlns:cat="http://nrg.wustl.edu/catalog" xmlns:icr="http://icr.ac.uk/icr" xmlns:pipe="http://nrg.wustl.edu/pipe" xmlns:prov="http://www.nbirn.net/prov" xmlns:scr="http://nrg.wustl.edu/scr" xmlns:val="http://nrg.wustl.edu/val" xmlns:wrk="http://nrg.wustl.edu/workflow" xmlns:xdat="http://nrg.wustl.edu/security" xmlns:xnat="http://nrg.wustl.edu/xnat" xmlns:xnat_a="http://nrg.wustl.edu/xnat_assessments" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<xnat:scanner manufacturer="Leica Biosystems" model="GT450"></xnat:scanner>

<xnat:prearchivePath>/data/xnat/prearchive/MICROSCOPY_DEV/20240910_170828281/dicom_upload</xnat:prearchivePath>

<xnat:scans>

<xnat:scan ID="1_3_6_1_4_1_36533_235150831662121946981579010430106254171222" UID="1.3.6.1.4.1.36533.235150831662121946981579010430106254171222" xsi:type="xnat:smScanData">

<xnat:scanner manufacturer="Leica Biosystems" model="GT450"/>

<xnat:modality>SM</xnat:modality>

<xnat:frames>1</xnat:frames>

<xnat:file URI="SCANS/1_3_6_1_4_1_36533_235150831662121946981579010430106254171222/DICOM/scan_1_3_6_1_4_1_36533_235150831662121946981579010430106254171222_catalog.xml" content="RAW" format="DICOM" label="DICOM" xsi:type="xnat:resourceCatalog"/>

</xnat:scan>

</xnat:scans> 

  This file is the one that your SAXParser is trying to parse.  

  My guess - and again, apologies if I'm barking up entirely the wrong tree - is that in your case, that file has zero length, because of a failure in the session building process. This would explain the error you reported: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.


 So the first thing to do is to go and check this out and see whether my assumption is correct.

  If that does prove to be true, then how can you find out what is causing it?

  The next diagnostic is to list the actual data directory in the prearchive. In my case, here's what I see:

xnat@xnatdev2204:~$ ls /data/xnat/prearchive/MICROSCOPY_DEV/20240910_170828281/dicom_upload

SCANS  dcmtoxnat.log

The SCANS directory has all the DICOM series that I have uploaded. The dcmtoxnat.log tells me what XNAT found when it tried to build the session. In my case, I see this:

xnat@xnatdev2204:~$ cat /data/xnat/prearchive/MICROSCOPY_DEV/20240910_170828281/dicom_upload/dcmtoxnat.log

 session attribute session_type has no value

 session attribute fields/field has no value

 session attribute dcmPatientBirthDate: DICOM attribute org.nrg.dcm.FixedDicomAttributeIndex@10004f(0010,0030) has bad value (); unable to derive attribute(s) [dcmPatientBirthDate]

 session attribute date: DICOM attribute org.nrg.dcm.FixedDicomAttributeIndex@8003f(0008,0020) has bad value (); unable to derive attribute(s) [date]

 session attribute time: DICOM attribute org.nrg.dcm.FixedDicomAttributeIndex@8004f(0008,0030) has bad value (); unable to derive attribute(s) [time]

 session attribute study_id has no value

 session attribute dcmPatientWeight has no value

 session attribute dcmPatientId has no value

 session attribute dcmPatientName has no value

 session attribute dcmAccessionNumber has no value

 session attribute acquisition_site has no value

 session attribute operator has no value

 scan 1_3_6_1_4_1_36533_235150831662121946981579010430106254171222 attribute startTime has no value

 scan 1_3_6_1_4_1_36533_235150831662121946981579010430106254171222 attribute start_date has no value

 scan 1_3_6_1_4_1_36533_235150831662121946981579010430106254171222 attribute requestedProcedureDescription has no value

 scan 1_3_6_1_4_1_36533_235150831662121946981579010430106254171222 attribute protocolName has no value

 scan 1_3_6_1_4_1_36533_235150831662121946981579010430106254171222 attribute bodyPartExamined has no value

 scan 1_3_6_1_4_1_36533_235150831662121946981579010430106254171222 attribute scanner has no value

 scan 1_3_6_1_4_1_36533_235150831662121946981579010430106254171222 attribute series_description has no value

 1_3_6_1_4_1_36533_235150831662121946981579010430106254171222 attribute orientation has no value

  Luckily, these were all issues with my input data's DICOM conformance, but XNAT didn't regard these as critical errors and so was still able to build the session. My working hypothesis would be that your dcmtoxnat.log file might contain one or more errors that are critical to building the session.

  I hope that's useful, but even if it isn't, I hope that gives a bit of insight in terms of what happens when things go into the prearchive.

  Best wishes,

Simon


Choon Hua Thng

unread,
Mar 5, 2025, 8:00:05 AM3/5/25
to xnat_discussion

Dear Simon

Thanks for your tips !

I am always grateful to learn trouble-shooting tips.

Yes. The error was at the prearchive

A screenshot of a computer

AI-generated content may be incorrect.

A close-up of a computer screen

AI-generated content may be incorrect.

Both files are zero bytes.

Something went wrong.

? session builder problem.

 

A screenshot of a computer

AI-generated content may be incorrect.

Moore, Charlie

unread,
Mar 5, 2025, 10:31:34 AM3/5/25
to xnat_di...@googlegroups.com
Hi there,

My guess is you're running into this https://radiologics.atlassian.net/browse/XNAT-4527 . You can confirm that by looking at the logs.

Thanks,
Charlie

From: xnat_di...@googlegroups.com <xnat_di...@googlegroups.com> on behalf of Choon Hua Thng <thn...@gmail.com>
Sent: Wednesday, March 5, 2025 7:00 AM
To: xnat_discussion <xnat_di...@googlegroups.com>

 


The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.

Simon Doran

unread,
Mar 6, 2025, 3:16:41 AM3/6/25
to xnat_discussion
Hi Charlie,

  When Choon posted the original query, I didn't want to speculate further without any evidence, but that would have been my assumption as well. It's not enough just to enable a session type in XNAT. The session builder still needs to know what to do with the DICOM tags that are modality-specific.

  IIRC, in the schema, the session objects for many less frequently encountered DICOM image types are "shells" that aren't not fleshed out at all, whereas for the major radiology data types specific data are included in the session XMLs - e.g., MR Sessions include MR-related data such as TR, TE and field strength. Could you expand a bit on your reply to Rick at the bottom of https://radiologics.atlassian.net/browse/XNAT-4527:


Charlie Moore September 29, 2020 at 8:31 PM

The changes make XNAT able to create a session object from more modalities/SOP classes, but it doesn't address the problem in general. I made XNAT-6490: Allow creation of an XNAT session object from RT seriesClosed to point out that we made some improvements in 1.8.


Z-Rick Herrick June 18, 2020 at 11:13 PM

As long as the modality of the scans are supported, this should now work. The session is built in the prearchive with the XnatOtherimagesessiondataBean data type, and the scans are then merged into the existing session.

  
  From what Rick said, it seems as if some sort of "vanilla" session should get built anyway but with no modality-specific metadata. However, your later comment appears to indicate that this doesn't work properly? I understand that it's a lot of work to fully support all the different possibilities, but where does the issue come if all that is required is something generic, whose sole purpose is "just to get the DICOM data into XNAT"?

  Best wishes,

Simon

Choon Hua Thng

unread,
Mar 6, 2025, 3:18:29 AM3/6/25
to xnat_discussion
Thanks Charlie.
I think u r right.
dicom.log
2025-03-06 07:51:32,735 [threadPoolExecutorFactoryBean-1] WARN  org.nrg.dcm.xnat.DICOMSessionBuilder - 
Session builder not implemented for SOP class(es) [1.2.840.10008.5.1.4.1.1.77.1.5.1] or modality(ies) [OP], trying default session builder factory

XNAT ver 1.8.10 installed on Docker, win 11, linux subsystem

Any advice ?

Choon

Timothy Olsen

unread,
Mar 8, 2025, 9:36:03 PM3/8/25
to xnat_discussion
Can you share your opSessionData and opScanData definitions?

And maybe some sample DICOM data you could share.

Thanks,
Tim

Choon Hua Thng

unread,
May 10, 2025, 8:50:06 PM5/10/25
to xnat_di...@googlegroups.com
Write a plugin to import Modaltiy = OP and Modaltiy = SC

I managed to write a plugin to import Dicom Modality = OP and SC and I would like to share the detailed steps to help other users.
I am a computer hobbyist and not an IT professional, so pls feel free to provide tips to improve my steps and correct my errors. 

I have windows 11 running on Surface Pro 9 with xnat 1.9.1.2 on Vagrant/Virtualbox. 

Steps:

I used the xnat-template-plugin from Rick Herrick: 

I placed the following edited files (see attachment) in the following path from the src directory of the xnat-template-plugin above:

src\main\java\org\nrg\dcm\xnat

DICOMSessionBuilder.java
OPScanAttributes.java
OPSessionAttributes.java
SCScanAttributes.java
SCSessionAttributes.java
XnatOpscandataBeanFactory.java
XnatOpsessiondataBeanFactory.java
XnatScscandataBeanFactory.java
XnatScsessiondataBeanFactory.java

src\main\resources\schemas\sc
sc.xsd

src\main\resources\META-INF\resources\templates\screens\
XDATScreen_edit_xnat_scSessionData.vm
XDATScreen_report_xnat_scSessionData.vm

I edited the build.gradle file provided in the xnat-template-plugin repo. (see attached)

I installed openjdk8 from Azul zulu on my surface pro. 

I executed the gradle build with the command provided in the README.md:

./gradlew xnatDataBuilder xnatPluginJar`

I stopped tomcat  : 
service tomcat9 stop

Then I went to the following directory of the downloaded repo :
build\libs

and copied the following file:
xnat-template-1.0.0-SNAPSHOT-xpl.jar 

to: 
/data/xnat/home/plugins

Then restarted tomcat:
service tomcat9 start

Login as admin and " Administer -Data Type - set up additional data type"

Then it worked. 

Details of the edits : 
The source files are found in Maven Central:

The *Attributes.java were modified from existing files related to OPT found in the following path:
dicom-xnat-mx-1.9.1-sources\org\nrg\dcm\xnat

The beanfactory  files were modified from XnatSmsessiondataBeanFactory.java and XnatSmscandataBeanFactory.java found in this repo : 

build.gradle has the following lines inserted, based on the repo above from Kate Alpert:
    implementation "org.apache.commons:commons-lang3"
    implementation "org.slf4j:slf4j-api"
    implementation "log4j:log4j"

    implementation "org.nrg:dicom-xnat-mx"
    implementation "org.nrg:dicom-xnat-sop"
    
    implementation "org.nrg:PrearcImporter"

build.gradle had variable fields for versions which were manually filled.
    vXnat = "1.9.1.2"
     id "org.nrg.xnat.build.xnat-data-builder" version "1.9.1"
         mavenBom "org.nrg:parent:1.9.1.2"
         implementation enforcedPlatform("org.nrg:parent:1.9.1.2")


DICOMSessionBuilder had the following lines inserted:
sessionTypeAttrs.put(XnatOpsessiondataBean.class, OPSessionAttributes.get());
sessionBeanBuilders.put(XnatOpsessiondataBean.class, ImmutableMap.copyOf(imageSessionBeanBuilders));

XSD for OP is already specified in xnat.xsd
XSD for SC was not specified and was written based on xnat documentation:

Velocity templat (vm)
I had to copy and modify the files which are required for the display:

I copied from the files for CT which are located:
    "~\xnat-data-models-1.9.1.2-sources\META-INF\resources\base-templates\screens\XDATScreen_edit_xnat_ctSessionData.vm"

    "~\xnat-data-models-1.9.1.2-sources\META-INF\resources\base-templates\screens\XDATScreen_report_xnat_ctSessionData.vm"

I replaced occurences of "ctSession" with "scSession" and replaced CT with SC in line related to the document title at the beginning of the file. 

I added the following command after the ## comments in the report vm file:
    \verb|#parse($turbineUtils.getTemplateName("_report",$om.getXSIType(),$project))| 

I added the following command after the ## comments in the edit vm file : 
    \verb|#parse($turbineUtils.getTemplateName("edit",$om.getXSIType(),$project,"edit"))|
    

    Then save into :

    "~\xnat-template-plugin\src\main\resources\META-INF\resources\templates\screens\XDATScreen_edit_xnat_scSessionData.vm"

    "~\xnat-template-plugin\src\main\resources\META-INF\resources\templates\screens\XDATScreen_report_xnat_scSessionData.vm"


Afternote:
The XNAT OHIF plugin is a game-changer and a force multiplier.
Users can now annotate directly in XNAT and save their annotations in open formats (NIH AIM XML, DICOM RT STRUCT, DICOM Seg).
I anticipate that more non-radiology subspecialties would be using XNAT in the near future. I hope this post will help someone get their non-traditional images into XNAT.


Choon
SingHealth Data Science, Innovation and Research Platforms (SDIRP)


From: Choon Hua Thng <thn...@gmail.com>
Sent: Saturday, March 15, 2025 12:18 PM

To: xnat_di...@googlegroups.com <xnat_di...@googlegroups.com>
Subject: Re: [XNAT Discussion] Modality = Opthalmic Photography; Error on image upload
 
Sorry for delay
I had to ask permission from the PI to contribute the image. 

OpScanData XML
<xdat:element_security xmlns:arc="http://nrg.wustl.edu/arc" xmlns:val="http://nrg.wustl.edu/val" xmlns:pipe="http://nrg.wustl.edu/pipe" xmlns:icr="http://icr.ac.uk/icr" xmlns:wrk="http://nrg.wustl.edu/workflow" xmlns:scr="http://nrg.wustl.edu/scr" xmlns:xdat="http://nrg.wustl.edu/security" xmlns:cat="http://nrg.wustl.edu/catalog" xmlns:prov="http://www.nbirn.net/prov" xmlns:xnat="http://nrg.wustl.edu/xnat" xmlns:xnat_a="http://nrg.wustl.edu/xnat_assessments" xmlns:template="http://nrg.wustl.edu/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" element_name="xnat:opScanData" secondary_password="0" secure_ip="0" secure="1" browse="1" sequence="0" quarantine="0" pre_load="0" searchable="1" secure_read="1" secure_edit="1" secure_create="1" secure_delete="1" accessible="1" singular="OP" plural="OP" xsi:schemaLocation="http://nrg.wustl.edu/workflow http://localhost/schemas/workflow.xsd http://nrg.wustl.edu/catalog http://localhost/schemas/catalog.xsd http://nrg.wustl.edu/pipe http://localhost/schemas/repository.xsd http://nrg.wustl.edu/scr http://localhost/schemas/screeningAssessment.xsd http://nrg.wustl.edu/template http://localhost/schemas/template.xsd http://nrg.wustl.edu/arc http://localhost/schemas/project.xsd http://icr.ac.uk/icr http://localhost/schemas/roi.xsd http://nrg.wustl.edu/val http://localhost/schemas/protocolValidation.xsd http://nrg.wustl.edu/xnat http://localhost/schemas/xnat.xsd http://nrg.wustl.edu/xnat_assessments http://localhost/schemas/assessments.xsd http://www.nbirn.net/prov http://localhost/schemas/birnprov.xsd http://nrg.wustl.edu/security http://localhost/schemas/security.xsd">
<xdat:primary_security_fields>
<xdat:primary_security_field>xnat:opScanData/project</xdat:primary_security_field>
<xdat:primary_security_field>xnat:opScanData/sharing/share/project</xdat:primary_security_field>
</xdat:primary_security_fields>
<xdat:element_actions>
<xdat:element_action element_action_name="edit" display_name="Edit" sequence="0" image="e.gif" secureAccess="edit"/>
<xdat:element_action element_action_name="xml" display_name="View XML" sequence="1" image="r.gif" grouping="View"/>
<xdat:element_action element_action_name="xml_file" display_name="Download XML" sequence="2" image="save.gif"/>
<xdat:element_action element_action_name="email_report" display_name="Email" sequence="3" image="right2.gif" popup="always"/>
</xdat:element_actions>
</xdat:element_security>


OPSessionData XML
<xdat:element_security xmlns:arc="http://nrg.wustl.edu/arc" xmlns:val="http://nrg.wustl.edu/val" xmlns:pipe="http://nrg.wustl.edu/pipe" xmlns:icr="http://icr.ac.uk/icr" xmlns:wrk="http://nrg.wustl.edu/workflow" xmlns:scr="http://nrg.wustl.edu/scr" xmlns:xdat="http://nrg.wustl.edu/security" xmlns:cat="http://nrg.wustl.edu/catalog" xmlns:prov="http://www.nbirn.net/prov" xmlns:xnat="http://nrg.wustl.edu/xnat" xmlns:xnat_a="http://nrg.wustl.edu/xnat_assessments" xmlns:template="http://nrg.wustl.edu/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" element_name="xnat:opSessionData" secondary_password="0" secure_ip="0" secure="1" browse="1" sequence="0" quarantine="0" pre_load="0" searchable="1" secure_read="1" secure_edit="1" secure_create="1" secure_delete="1" accessible="1" singular="OP" plural="OP" xsi:schemaLocation="http://nrg.wustl.edu/workflow http://localhost/schemas/workflow.xsd http://nrg.wustl.edu/catalog http://localhost/schemas/catalog.xsd http://nrg.wustl.edu/pipe http://localhost/schemas/repository.xsd http://nrg.wustl.edu/scr http://localhost/schemas/screeningAssessment.xsd http://nrg.wustl.edu/template http://localhost/schemas/template.xsd http://nrg.wustl.edu/arc http://localhost/schemas/project.xsd http://icr.ac.uk/icr http://localhost/schemas/roi.xsd http://nrg.wustl.edu/val http://localhost/schemas/protocolValidation.xsd http://nrg.wustl.edu/xnat http://localhost/schemas/xnat.xsd http://nrg.wustl.edu/xnat_assessments http://localhost/schemas/assessments.xsd http://www.nbirn.net/prov http://localhost/schemas/birnprov.xsd http://nrg.wustl.edu/security http://localhost/schemas/security.xsd">
<xdat:primary_security_fields>
<xdat:primary_security_field>xnat:opSessionData/project</xdat:primary_security_field>
<xdat:primary_security_field>xnat:opSessionData/sharing/share/project</xdat:primary_security_field>
</xdat:primary_security_fields>
<xdat:element_actions>
<xdat:element_action element_action_name="edit" display_name="Edit" sequence="0" image="e.gif" secureAccess="edit"/>
<xdat:element_action element_action_name="xml" display_name="View XML" sequence="1" image="r.gif" grouping="View"/>
<xdat:element_action element_action_name="xml_file" display_name="Download XML" sequence="2" image="save.gif"/>
<xdat:element_action element_action_name="email_report" display_name="Email" sequence="3" image="right2.gif" popup="always"/>
</xdat:element_actions>
</xdat:element_security>




Sent: Sunday, March 9, 2025 10:36 AM
DICOMSessionBuilder.java
sc.xsd
XDATScreen_edit_xnat_scSessionData.vm
XDATScreen_report_xnat_scSessionData.vm
build.gradle
OPScanAttributes.java
OPSessionAttributes.java
SCScanAttributes.java
SCSessionAttributes.java
XnatOpscandataBeanFactory.java
XnatOpsessiondataBeanFactory.java
XnatScscandataBeanFactory.java
XnatScsessiondataBeanFactory.java

Will Horton

unread,
May 12, 2025, 9:24:20 PM5/12/25
to xnat_di...@googlegroups.com
Hello Choon,
This is a fantastic contribution to the XNAT community, both in code and in your explanation of your approach. We happen to be working on a series of updates to supported modalities for future release and would love to pull your work into the core XNAT product, with attribution and your permission. We would also really benefit from being able to work with any sample anonymized Ophthalmic DICOM data that you might have available, for use in testing and QA. 

Let me know your thoughts. 

Regards,
Will 




--
Will Horton
Director of Product


Choon Hua Thng

unread,
May 12, 2025, 11:22:46 PM5/12/25
to xnat_discussion
Thanks for your kind words, Will. 
Pls feel free to use any portion of what I had posted. 
I am in the process of contacting the data owner of Opthalmic Photos to consider helping XNAT. 

Choon
Reply all
Reply to author
Forward
0 new messages