Manage the slicer.modules.sampleDataSources dictionary. The dictionary keys are categories of sample data sources. The BuiltIn category is managed here. Modules or extensions can register their own sample data by creating instances of the SampleDataSource class. These instances sho
| 516 | |
| 517 | |
| 518 | class SampleDataLogic: |
| 519 | """Manage the slicer.modules.sampleDataSources dictionary. |
| 520 | The dictionary keys are categories of sample data sources. |
| 521 | The BuiltIn category is managed here. Modules or extensions can |
| 522 | register their own sample data by creating instances of the |
| 523 | SampleDataSource class. These instances should be stored in a |
| 524 | list that is assigned to a category following the model |
| 525 | used in registerBuiltInSampleDataSources below. |
| 526 | |
| 527 | Checksums are expected to be formatted as a string of the form |
| 528 | ``<algo>:<digest>``. For example, ``SHA256:cc211f0dfd9a05ca3841ce1141b292898b2dd2d3f08286affadf823a7e58df93``. |
| 529 | """ |
| 530 | |
| 531 | @staticmethod |
| 532 | def registerCustomSampleDataCategory(category, title): |
| 533 | """Register a sample data category and its display properties. |
| 534 | |
| 535 | Call this before (or independently of) :func:`registerCustomSampleDataSource` to set |
| 536 | human-readable metadata for a category. |
| 537 | |
| 538 | :param category: Machine-readable category identifier (used as the key in |
| 539 | ``slicer.modules.sampleDataSources``). |
| 540 | :param title: Human-readable, translatable category title shown in the SampleData module GUI. |
| 541 | """ |
| 542 | try: |
| 543 | slicer.modules.sampleDataSourceCategories |
| 544 | except AttributeError: |
| 545 | slicer.modules.sampleDataSourceCategories = {} |
| 546 | |
| 547 | if category not in slicer.modules.sampleDataSourceCategories: |
| 548 | slicer.modules.sampleDataSourceCategories[category] = {} |
| 549 | |
| 550 | slicer.modules.sampleDataSourceCategories[category]["title"] = title |
| 551 | |
| 552 | @staticmethod |
| 553 | def registerCustomSampleDataSource(category="Custom", |
| 554 | sampleName=None, uris=None, fileNames=None, nodeNames=None, |
| 555 | customDownloader=None, thumbnailFileName=None, |
| 556 | loadFileTypes=None, loadFiles=None, loadFileProperties={}, |
| 557 | checksums=None, |
| 558 | loadFileType=None): |
| 559 | """Adds custom data sets to SampleData. |
| 560 | :param category: Section title of data set in SampleData module GUI. |
| 561 | :param sampleName: Displayed name of data set in SampleData module GUI. |
| 562 | :param thumbnailFileName: Displayed thumbnail of data set in SampleData module GUI, |
| 563 | :param uris: Download URL(s). |
| 564 | :param fileNames: File name(s) that will be loaded. |
| 565 | :param nodeNames: Node name(s) in the scene. |
| 566 | :param customDownloader: Custom function for downloading. |
| 567 | :param loadFileTypes: file format name(s) (if not specified then the default file reader will be used). |
| 568 | :param loadFiles: Boolean indicating if file(s) should be loaded. By default, the function decides. |
| 569 | :param loadFileProperties: custom properties passed to the IO plugin. |
| 570 | :param checksums: Checksum(s) formatted as ``<algo>:<digest>`` to verify the downloaded file(s). For example, ``SHA256:cc211f0dfd9a05ca3841ce1141b292898b2dd2d3f08286affadf823a7e58df93``. |
| 571 | :param loadFileType: deprecated, use ``loadFileTypes`` instead. |
| 572 | """ |
| 573 | |
| 574 | # For backward compatibility (allow using "loadFileType" instead of "loadFileTypes") |
| 575 | if (loadFileType is not None) and (loadFileTypes is not None): |
no outgoing calls