icon-developing.png
XNAT Development
Codebase


Best Practices for Development


Mercurial


Other topics

[Edit Nav]

Enhanced Zip Support

This feature is an off-shoot of the support for multiframe DICOM data.

Background

You can currently store a zip file as a basic entry in a catalog.
<?xml version="1.0" encoding="UTF-8"?>
<cat:Catalog>
    <cat:entries>
        <cat:entry URI="./freesurfer.zip"/>
    </cat:entries>
</cat:Catalog>
You can also reference a file within the zip as a basic entry.
<?xml version="1.0" encoding="UTF-8"?>
<cat:Catalog>
    <cat:entries>
        <cat:entry URI="./freesurfer.zip!/mri/brainmask.mgz"/>
        <cat:entry URI="./freesurfer.zip!/mri/aseg_with_cc.mgz" format="MGZ" content="segmentation volume"/>
        <cat:entry URI="./freesurfer.zip!/mri/norm.mgz" format="MGZ" content="in volume"/>
    </cat:entries>
</cat:Catalog>
The problem with the current support is that it doesn't support accessing non-referenced files in the zip (which could be easily done) and is out of sync with the upcoming support for DICOM Multiframe data. Multiframe data will will require a seperate variable for identifying the frame for a entry within a multiframe file. Something like...
<?xml version="1.0" encoding="UTF-8"?>
<cat:Catalog URI="./multiframe.dcm" xsi:type="cat:multiFrameDCMCatalog">
    <cat:entries>
        <cat:entry frame="1" ...  xsi:type="cat:multiFrameDCMEntry"/>
        <cat:entry frame="2" ...  xsi:type="cat:multiFrameDCMEntry"/>
        <cat:entry frame="3" ...  xsi:type="cat:multiFrameDCMEntry"/>
    </cat:entries>
</cat:Catalog>
FYI, the variables in the multiFrameDCMCatalog and multiFrameDCMEntry are still to be decided.

Goals

XNAT should support listing all files in a zip via the REST api (i.e. /REST/experiment/dsfds/resources/something/files/somezip.zip?format=html)
XNAT should support tags on the individual entries in a zip (but the entries should not be required, as they are already referenced by the zip manifest).
Any new structure should prevent duplicate downloads of the same ZIP file (when downloading all data).

Proposal

To do this, I would recommend adding a new cat:catalog extension in the catalog schema. The new type could be defined something like cat:ZipCatalog. The catalog itself would reference a zip (catalogs don't usually reference files). The logic for handling downloads of the zip and listing of files within it could be defined based on the ZipCatalog type. The user could optionally add entries in that catalog which would add tags to the individual entries. These cat:entries would be supplemental to the zip manifest, rather then overriding it.

Example:
<?xml version="1.0" encoding="UTF-8"?>
<cat:Catalog URI="./freesurfer.zip" xsi:type="cat:ZipCatalog">
    <cat:entries>
        <cat:entry URI="mri/brainmask.mgz" format="MGZ" content="brain mask"/>
        <cat:entry URI="mri/aseg_with_cc.mgz" format="MGZ" content="segmentation volume"/>
        <cat:entry URI="mri/norm.mgz" format="MGZ" content="in volume"/>
        <cat:entry URI="stats/aseg.stats" format="FS_STATS" content="$stats_type stats"/>
    </cat:entries>
</cat:Catalog>