Querying and persisting clinical data (Age, MMSE.......) in XNAT

24 views
Skip to first unread message

Reda Fritet

unread,
Jan 8, 2026, 10:17:22 AM (13 days ago) Jan 8
to xnat_discussion

Hello everyone,

I have a question regarding accessing and modifying clinical or derived data directly via the XNAT PostgreSQL database.

In my XNAT 1.8.9 instance, I noticed that some information displayed in the UI (for example Patient Age shown in the MR Session details) is read from the DICOM files at display time and does not appear to be persisted in PostgreSQL (e.g. dcmpatientbirthdate is NULL, and there is no age column in xnat_subjectdata).

On the other hand, values entered through Custom Field Sets / Form Manager (such as MMSE scores) are stored in PostgreSQL (for example in xnat_experimentdata.custom_fields as JSONB), and can be queried with SQL.

My questions are:

  1. Is it recommended or supported to insert or update values directly in PostgreSQL (e.g. updating custom_fields JSONB) for derived or clinical variables like MMSE or Age?

  2. For DICOM-derived values such as PatientAge (0010,1010), is there a recommended way to persist them in XNAT so that they become searchable via SQL or XNAT search (e.g. via Subject Variables, Assessors, or custom datatypes)?

  3. Are there best practices for making DICOM-derived metadata queryable (without breaking XNAT indexing, permissions, or audit trails)?

The goal is to enable queries such as “all sessions/subjects with age = 55” or “MMSE ≥ 24” in a safe and XNAT-compliant way.

Thank you in advance for your guidance.

Best regards,
Reda

Timothy Olsen

unread,
Jan 8, 2026, 10:29:41 AM (13 days ago) Jan 8
to xnat_di...@googlegroups.com
Age is a calculated field.  If you have the subject dob (or yob) populated and the date populated in your experiment, then the form should show the age.  The Age column should be available in the Edit Columns option when you list all of your imaging sessions, either on the project page or from Data -> [Modality] Sessions.  Are you seeing it there?

Tim

Timothy R Olsen 

Founder, President




--
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/27230e22-2bcc-45d4-a998-a5549d936ebdn%40googlegroups.com.

Reda Fritet

unread,
Jan 8, 2026, 10:48:33 AM (13 days ago) Jan 8
to xnat_discussion

Thanks for the clarification. In my instance, session dates are populated, but the subject DOB/YOB isn’t stored (likely due to anonymization), so Age can’t be calculated. I also don’t see an Age column under Edit Columns when listing sessions. Is Age computed strictly from stored DOB/YOB, or can it also use the DICOM PatientAge (0010,1010) tag?

Timothy Olsen

unread,
Jan 8, 2026, 11:23:51 AM (13 days ago) Jan 8
to xnat_di...@googlegroups.com
XNAT doesn't currently support populating the Age from the DICOM. I'm not exactly sure why it was never added, but at present it isn't there.  Maybe its because we were more focused on the DOB, which was more complicated.

I know some people have written scripts to pull the YOB and Age from the DICOM, but I don't think any of those have ever been made public.  It would probably be easy to have Claude write a script that does it and then throw it in a container that runs automatically for each session.  It's annoying to have to do that, apologies.  Or you could add it to your Custom Form and manually input it.

Tim

Timothy R Olsen 

Founder, President



Elena Baumeister

unread,
Jan 20, 2026, 8:42:07 AM (yesterday) Jan 20
to xnat_discussion
Hello Reda, 
how did you manage to set the custom_fields. Are you doing it via a Python script? In my case I can set them, but next time I wanna get them from a specific scan they are not existing anymore.
So maybe you can show a code snippet?

Kind regards,
Elena

Reply all
Reply to author
Forward
0 new messages