Force Session modality to xnat:petmrSessionData

38 views
Skip to first unread message

dev

unread,
Nov 19, 2021, 12:12:24 PM11/19/21
to xnat_discussion
Hi,

We are using Xnat 1.8.2.2 build: 4, and would like to force the session Type to PET and MR instead of only PET.
I have seen the option 'Separate PET-MR (Site Wide)' in the admin interface and in existing project settings.

But when I set the value to 'Create as PET/MR session', sessions are always MR while the Dicom Modality is (0008,0060) Modality PT.

After a quick analysis of the Xnat code, I see the session type choice is made before the creation of prearchive/prj/tmpSession/catalog.xml

Exemple of catalog.xml : 
<?xml version="1.0" encoding="UTF-8"?>
<xnat:MRSession ID="">
...

Is it possible to force the session to xnat:petmrSessionData ?

Moore, Charlie

unread,
Nov 19, 2021, 1:01:33 PM11/19/21
to xnat_di...@googlegroups.com
Hello there,

Could you include some other information?
  1. Do you have any plugins installed?
  2. How are you uploading the session?
Thanks,
Charlie

From: xnat_di...@googlegroups.com <xnat_di...@googlegroups.com> on behalf of dev <icm.inst...@gmail.com>
Sent: Friday, November 19, 2021 11:12 AM
To: xnat_discussion <xnat_di...@googlegroups.com>
Subject: [XNAT Discussion] Force Session modality to xnat:petmrSessionData
 

* External Email - Caution *

--
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 on the web visit https://groups.google.com/d/msgid/xnat_discussion/870ff3ac-f5ce-4749-80db-1a955e210f46n%40googlegroups.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.

dev

unread,
Nov 24, 2021, 5:02:41 AM11/24/21
to xnat_discussion
I am indeed using a plugin to create new xnat projects with a custom name.
I 'll try to debug this method.

Here is my code :
XnatProjectdata xnatProject = XnatProjectUtils.createProject (projectId, projectTitle, "", true, true, _xnatUser);

And then :

/**
* Create an XNAT project
* @param projectId
* @param projectTitle
* @param xnatUser
*/
static public XnatProjectdata createProject (final String projectId, final String projectTitle, final String projectDescription, final boolean disableAutoarchive, final boolean setPipelines, final UserI xnatUser) {
LogUtils.logDebug (XnatProjectUtils.class.getName() + ".createProject");
LogUtils.logDebug ("projectId = " + projectId);
LogUtils.logDebug ("projectTitle = " + projectTitle);
LogUtils.logDebug ("xnatUser = " + xnatUser.getLogin ());
if (!GeneralUtils.isAdminUser (xnatUser)) {
LogUtils.logString ("User [" + xnatUser.getLogin() + "] is not an XNAT administrator.");
return null;
}

XnatProjectdata xnatProject = XnatProjectdata.getProjectByIDorAlias (projectId, xnatUser, false);
if (xnatProject != null) {
LogUtils.logDebug ("Found project assignment of " + xnatProject.getProject () + " for study ID " + projectId);
return xnatProject;
}
else {
LogUtils.logDebug ("Found no project with ID or alias [" + projectId + "]");

// for the following code, refer to org.nrg.xnat.turbine.modules.actions.AddProject
xnatProject = new XnatProjectdata (xnatUser);

try {
xnatProject.setId (projectId);
xnatProject.setSecondaryId (projectTitle);
xnatProject.setName (projectTitle);
if (!("".equals (projectDescription))) {
xnatProject.setDescription (projectDescription);
}
xnatProject.trimProjectFields ();

final PersistentWorkflowI wrk = PersistentWorkflowUtils.getOrCreateWorkflowData (null, xnatUser, XnatProjectdata.SCHEMA_ELEMENT_NAME, xnatProject.getId(), xnatProject.getId(), new EventDetails (EventUtils.CATEGORY.PROJECT_ADMIN, EventUtils.TYPE.PROCESS, EventUtils.getAddModifyAction(xnatProject.getXSIType (), true), "Project not existant", "Creating project for automation"));
final EventMetaI ci = wrk.buildEvent ();
// prepare(?) the workflow for saving (?)
PersistentWorkflowUtils.save (wrk, ci);

// "real" saving of the project (with verification of authorization but since we're considered admin here, it causes no problem)
xnatProject = BaseXnatProjectdata.createProject(xnatProject, xnatUser, false, true, ci, "protected");

final XnatProjectdata xnatProjectPostSave = new XnatProjectdata (xnatUser);
xnatProjectPostSave.setId (xnatProject.getId ());
xnatProjectPostSave.setSecondaryId (xnatProject.getSecondaryId ());
xnatProjectPostSave.setName (xnatProject.getName ());
xnatProjectPostSave.getItem ().setUser(xnatUser);

xnatProjectPostSave.initGroups ();

Groups.reloadGroupForUser (xnatUser, xnatProjectPostSave.getId() + "_" + BaseXnatProjectdata.OWNER_GROUP);
// for the main folder for saving on the disk
ArcProject arcProject = new ArcProject (xnatUser);
arcProject.setCurrentArc ("arc001");
xnatProjectPostSave.initArcProject (arcProject, xnatUser, ci);

// set project accessibility to protected
Permissions.setDefaultAccessibility (xnatProject.getId (), "protected", true, xnatUser, ci);
// complete(?) the workflow
PersistentWorkflowUtils.complete (wrk, ci);

// trigger event that a new project was created
final NrgEventService eventService = XDAT.getContextService ().getBean (NrgEventService.class);
eventService.triggerEvent (new XftItemEvent (XnatProjectdata.SCHEMA_ELEMENT_NAME, xnatProjectPostSave.getId (), XftItemEvent.UPDATE));

LogUtils.logString ("Project [" + projectId + "] created.");

//addProjectAdminOwner (projectId, xnatUser);

// set autoarchive to false
// NOTE : does not work above ie before the project is created
if (disableAutoarchive) {
setProjectPrearchivecode (projectId, 0, xnatUser);
}

if (setPipelines) {
final Map<String, Boolean> projectPipelines = XnatProjectUtils.getProjectPipelinesFromConfig (xnatUser);
addProjectPipelines (projectId, projectPipelines, xnatUser);
}
return xnatProject;
}
catch (Exception e) {
LogUtils.logException(e);
return null;
}
}
}



dev

unread,
Nov 24, 2021, 12:24:51 PM11/24/21
to xnat_discussion
I found the code I was looking for.
The session type (MR, PET, PETMR) seems to be detected using StudyInstanceUID and Modality.

The variable sessionBeanFactories contains 3 factories :
- XnatPetMrImageSessionDataBeanFactory (empty when I debug)
- SOPMapXnatImageSessionDataBeanFactory (24 row when I debug). Ex: 1.2.840.10008.5.1.4.1.1.2.1 -> {Class@2300} "class org.nrg.xdat.bean.XnatCtsessiondataBean"
- ModalityMapXnatImageSessionDataBeanFactory (17 rows). Ex: PT -> {Class@3480} "class org.nrg.xdat.bean.XnatPetsessiondataBean"

From what I understand, Xnat will instanciate the session type if SOPInstanceUid or Modality matches with the first factory.


In 
/org/nrg/dcm/xnat/DICOMSessionBuilder.java :

public XnatImagesessiondataBean call() throws IOException,NoUniqueSessionException,SQLException {
log.info("Building session for {}", studyInstanceUID);
final PrintWriterLogger sessionLog = new PrintWriterLogger(new File(fileSetDir, "dcmtoxnat.log"));
final List<XnatImagesessiondataBeanFactory> sessionBeanFactories = makeSessionBeanFactories(sessionLog);
try {
final XnatImagesessiondataBean session = makeSessionBean(sessionBeanFactories, studyInstanceUID);
}
[...]
}

dev

unread,
Nov 24, 2021, 12:31:17 PM11/24/21
to xnat_discussion
And factories are defined using .properties files :

private static final String LEAD_SCAN_TYPE_R = "/lead-scan-types.txt";
private static final String LEAD_SESSION_TYPE_R = "/lead-session-types.txt";
private static final String LEAD_MODALITY_R = "/lead-modalities.txt";
private static final String SOP_TO_SCAN_TYPE_R = "/series-scans.properties";
private static final String SOP_TO_SESSION_TYPE_R = "/study-sessions.properties";
private static final String MODALITY_TO_SESSION_TYPE_R = "/modality-sessions.properties";
private static final String PRIMARY_SOP_UID_R = "/primary-sops.txt";
private static final String UNKNOWN_UID_NAME = "Unknown UID Name:";

Reply all
Reply to author
Forward
0 new messages