Hi Sara
The ROIs aren't linked to the scan number directly as the scan, like the session, is an XNAT concept not a DICOM concept. They're linked to the images they refer to by the DICOM study, series and SOP instance UIDs of those images. The viewer matches ROIs to scans by the series UID of the scan and to the images by their SOP instance UID.
Creating a new ROI collection is perfectly possible but could be far from simple. Scan 3 and scan 4 could have different image matrices, Image Position Patient, Image Orientation Patient, Pixel Spacing, Slice Thickness or some combination of all these. Assuming you were able to correctly account for all these and get the contours in the correct place in 3D space and referencing the correct images, you would need to create a completely new AIM XML file or RT-STRUCT file as both of these have UIDs of their own (and other internal details) that must be set appropriately. Finally you would need to upload the new ROI collection via the plugin's REST API rather than directly manipulating the filesystem as the ROI collection metadata needs to be properly inserted into the database. It is not a find-and-replace operation in the AIM XML. If it was, it would be implemented already!
I don't know enough about pipelines to say if this is feasible or not.
ttfn
James