How to download markups as sample data

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')

You should be able to load markups directly into the scene. See this example (note that in this specific case loadFile is set to FALSE)

    SampleData.SampleDataLogic.registerCustomSampleDataSource(
      sampleName='Mouse Skull Reference Model',
      category='SlicerMorph',
      uris=['https://github.com/SlicerMorph/SampleData/blob/master/4074_skull.vtk?raw=true', 'https://raw.githubusercontent.com/SlicerMorph/SampleData/master/4074_S_lm1.fcsv?raw=true'],
      checksums=[None, None],
      loadFiles=[False, False],
      fileNames=['4074_skull.vtk','4074_S_lm1.fcsv'],
      nodeNames=['4074_skull', '4074_S_lm1'],
      thumbnailFileName=os.path.join(iconsPath, 'mouse3D.png'),
      loadFileType=['ModelFile','MarkupsFile'],
      customDownloader=self.downloadSampleDataInFolder,
)

Thanks for providing this example. I’m struggling a little bit to understand how to implement this. I need to set loadFiles to True? Do I then make an instance of the class and is there a method I should call to load the data?

Thanks for any additional help