How to download markups as sample data

DavidM
Thu, 09 May 2024 15:32:03 +0000
Support

Hi,

I am trying to create tests for a module I’m developing and as part of the test I’m using sampledata. I’m unable to download and import markup fiducial files (mrk.json) but have no issues with stl or vtp files. My code is below. I’m not sure what loadFileType should be set to, maybe this is the issue? I also run into the same problem if I try to read vtu files. Is there a documented way to import markup files as sampledata? Thank you for any help

def registerSampleData():

    import SampleData
    iconsPath = os.path.join(os.path.dirname(__file__), 'Resources/Icons')

    # load demo data
    SampleData.SampleDataLogic.registerCustomSampleDataSource(
        category="Heart",
        sampleName='RCA',
        uris='https://github.com/dmolony3/SlicerFractionalMyocardialMass/releases/download/SampleData/RCA.mrk.json',
        fileNames='RCA.mrk.json',
        nodeNames='RCA',
        loadFileType='MarkupsFile',
        )
    SampleData.SampleDataLogic.registerCustomSampleDataSource(
        category="Heart",
        sampleName='RCA_surface',
        uris='https://github.com/dmolony3/SlicerFractionalMyocardialMass/releases/download/SampleData/RCA_surface.vtp',
        fileNames='RCA_surface.vtp',
        nodeNames='RCA_surface',
        loadFileType='ModelFile',
        )

class FMMTest(ScriptedLoadableModuleTest):
    """
    This is the test case for your scripted module.
    Uses ScriptedLoadableModuleTest base class, available at:
    https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/ScriptedLoadableModule.py
    """

    def setUp(self):
        """ Do whatever is needed to reset the state - typically a scene clear will be enough.
        """
        slicer.mrmlScene.Clear()

    def runTest(self):
        """Run as few or as many tests as needed here.
        """
        self.setUp()
        self.test_FMM()

    def test_FMM(self):

        import SampleData
        registerSampleData()
        RCA = SampleData.downloadSample('RCA')
        self.delayDisplay('Loaded RCA markup')
        LCA = SampleData.downloadSample('LCA')
        self.delayDisplay('Loaded LCA markup')
        RCA_surface = SampleData.downloadSample('RCA_surface')
        self.delayDisplay('Loaded RCA surface')
        LCA_surface = SampleData.downloadSample('LCA_surface')
        self.delayDisplay('Loaded LCA surface')
        myocardium_surface = SampleData.downloadSample('myocardium_surface')
        self.delayDisplay('Loaded myocardium surface')
        myocardium_volume = SampleData.downloadSample('myocardium_volume')
        self.delayDisplay('Loaded myocardium volume')

        outputTable = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLTableNode', 'FMM')
        outputMesh = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLModelNode', 'Myocardium')

        # Test the module logic
        logic = FMMLogic()

        inputMMARMarkup = None
        self.delayDisplay('Processing starts.')
        outputTable, outputMesh = logic.segmentMesh(myocardium_surface, LCA, RCA, inputMMARMarkup, outputTable, outputMesh) # 3D

        self.delayDisplay('Processing ends.')

        self.delayDisplay('Test passed')

3 posts - 2 participants