merge projects / move all subjects/sessions?

208 views
Skip to first unread message

Daniel Drucker

unread,
Apr 16, 2021, 3:42:38 PM4/16/21
to xnat_discussion
In my initial ingest I ended up creating a lot more projects than I should have. For instance, I have "ACR QA 201801" and "ACR QA 2018", each with subjects and MR sessions in them.

How can I move all of the subjects and sessions from one into another, so I can remove the extraneous projects? (There will be overlapping subject names. There will not be any overlapping session labels.)

D

Moore, Charlie

unread,
Apr 16, 2021, 4:22:03 PM4/16/21
to xnat_di...@googlegroups.com
Hi Daniel,

Sorry, this is one of the things that has sat on the periphery of needing to get fixed for a long time without quite making it into a release. There's an open ticket to allow moving subjects here: https://issues.xnat.org/browse/XNAT-4350 . That ticket describes a workaround our largest XNAT instance frequently uses. All of the steps mentioned in the ticket are supported in the UI. From the session​ report page, click the Edit link in the actions box. From that page you can click the icons next to project, subject, or session:
  1. For project: you can move the session into a new project.
  2. For subject: you can reassign the session to a new subject within the project.
  3. For session: you can relabel the session.
Obviously, having to do all these steps is not fun. I would recommend (on a dev server, this stuff is pretty messy) trying out the REST call mentioned in the comments of the ticket. I haven't tried that REST call myself, but moving the subject record itself is not​ supported in the UI. The workaround from the ticket essentially describes skirting that problem and reconstructing the previous data around a new subject record.

All of the above assumes the scale of the subjects/sessions you need to fix is small. If it's large, you're going to want to script it. I can dig up some REST API endpoints for some operations you may find useful, but this has the potential to be rather complex. XNAT supports a lot of use cases with sharing like:
  1. Subject exists in project A, but is shared into project B.
  2. Subject has an MR session in project B, which gets shared back into A.
You'd want to make sure that everything does get properly moved​ and not just shared, so you can delete the old projects. My concern is that the REST call mentioned in the comments of XNAT-4350 will only share the subject​ record itself into the new project and leave the data orphaned behind. If that's true, then unfortunately I can't think of a better solution than essentially bulk-scripting the workaround listed in the description of the ticket.

Thanks,
Charlie


From: xnat_di...@googlegroups.com <xnat_di...@googlegroups.com> on behalf of Daniel Drucker <ddru...@mclean.harvard.edu>
Sent: Friday, April 16, 2021 2:42 PM
To: xnat_discussion <xnat_di...@googlegroups.com>
Subject: [XNAT Discussion] merge projects / move all subjects/sessions?
 

* External Email - Caution *

In my initial ingest I ended up creating a lot more projects than I should have. For instance, I have "ACR QA 201801" and "ACR QA 2018", each with subjects and MR sessions in them.

How can I move all of the subjects and sessions from one into another, so I can remove the extraneous projects? (There will be overlapping subject names. There will not be any overlapping session labels.)

D

--
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/57ac0177-aaa5-47c6-b357-ac989d09e51en%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.

Daniel Drucker

unread,
Apr 16, 2021, 9:55:36 PM4/16/21
to xnat_discussion
Hi Charlie,

That PUT API call you mentioned definitely did not work at all, and, worse, appears to leave the database in an inconsistent state.
Briefly,
  (a) You cannot move a subject to another project if there's already a subject by that name there.
  (b) If you move a subject to another project, their MR sessions don't go with them ... and where they do go is mysterious and leaves things inconsistent.

 I created a video showing the problem. Hopefully by the time you click this the HD version will be finished processing.

So 
  (1) it looks like there is still no good answer to how to do this
  (2) there seems to be a fairly serious bug here.

Moore, Charlie

unread,
Apr 19, 2021, 11:20:49 AM4/19/21
to xnat_di...@googlegroups.com
Hi Daniel,

I've watched the video, and I agree with (1) still, but the behavior does seem to be essentially what I would expect. First to address a minor point that's ultimately inconsequential, the reason the initial /data/subjects/SUBJECT_ID/projects/NEW_PROJECT_ID?primary=true URL didn't work is because SUBJECT_ID had to be the XNAT ID ("Accession #" in the UI) for the subject. Using the label ("BBB") instead of the ID ("IMAGESTEST_S00008") works only when you add /projects/PROJECT_ID, as you correctly identified. For the actual main content, I can recreate the behavior you're seeing, but there's some other things you might want to try out:
  1. In p2, if you add the "MR Sessions" tab (in the table at the bottom of the project report page), you should still see the missing session.
  2. From the subject report page in the project "p1" (for example, at 3:10 in your video), note that there is a "View All Available Data for This Subject" link. If you click that link, the session should show up. You probably aren't using to seeing that link at all as it only shows up when there's data that belongs to another project for the subject you're looking at.
The way to explain this behavior is in terms of XNAT's sharing feature, or really just subject/experiment ownership. It looks like that REST call moves exactly the subject object from p2 -> p1, and ignores any experiments under it. This means that you end up with:
  • Subject BBB belongs to project p1
  • MR Session Z for subject BBB belongs to project p2
This would explain why:
  1. You don't see BBB in the subject listing for project p2 (it doesn't belong to that project)
  2. You see an empty cell for MR Sessions for BBB in project p1 (the session doesn't belong to that project, technically)
If you still want to explore this route, try this:
  1. Go to the session page for Z.
  2. Click Edit.
  3. Click the icon next to the project field.
  4. Select p1, and confirm the move.
That should move the session so that it belongs to p1 along with the subject, and I think it should all look as you expect. As an aside, these types of considerations are part of why addressing XNAT-4350 is to an extent "hard". There are some use cases where some users would want to move the experiments along with the subject, some where the experiments should stay, and others where a subset should move.

Hopefully that helps.

Thanks,
Charlie

Sent: Friday, April 16, 2021 8:55 PM
To: xnat_discussion <xnat_di...@googlegroups.com>
Subject: Re: [XNAT Discussion] merge projects / move all subjects/sessions?
 

Daniel Drucker

unread,
Apr 19, 2021, 11:30:43 AM4/19/21
to xnat_discussion
Thanks - that makes sense.

So it turns out after looking more closely at my data that I don't really have a need for this move functionality right now I thought I had a long tail of mostly-similar autocreated projects that could be merged, but on examination it turns out I have a long tail of mostly-dissimilar autocreated projects that can't be merged. But fortunately, only admins (me) can see that big mess; each of my individual users only see the couple things in there that are theirs.

So, while I think this is functionality that probably should be worked on, I've determined that it is not actually critical to me and therefore as a typical American I don't care any more :D 
Reply all
Reply to author
Forward
0 new messages