Choosing input and output interfaces
What are input and output interfaces?¶
At some point in your development process, you need to choose an input and output interface for your algorithm. An interface tells you two important things. It determines:
- What needs to be read or stored, and where. It is essentially just the path to your data.
- How data is interpreted – which relates to the kind of data that is being used. Is it an image, heatmap, segmentation mask, contour, bounding box etc.?
From the code base that you are preparing, a Docker image will be built that can be run as a Docker container. Every time it runs, it should process one set of inputs: it could be two images of the same patient, and perhaps some additional information such as age or sex – but it should not be a batch of data with several patients.
Every input/output needs an interface¶
To differentiate between input/output elements, you need to define an interface for each element separately. They can be the same type, but the interfaces need to have a different name and point to a different file location. The same goes for outputs. So every input/output element has to have a unique interface option (as defined by a name): the same interface cannot be chosen twice.
Inside a running container, an algorithm will take inputs from the
/input/ folder to process them and store the outputs in
/output/. By choosing an interface, you determine that, for example, a lung CT image needs to be read from
/input/images/ct/*random_uuid*.mha. Your outputs – which may consist of a segmentation and a probability estimate – need to be stored as
Thus, if the directory tree in your Docker container has the following folder structure:
input/ ├─ images/ │ ├─ ct/ │ │ ├─*random_uuid*.mha output/ ├─ images/ │ ├─ covid-19-lesion-segmentation/ │ │ ├─ *random_uuid*.mha ├─ probability.json
It implies the use of the following interfaces, displayed in this diagram:
NOTE: Images require you to read and write randomly generated uuids, so hard-coding paths for these should be avoided. Rather, construct your read and write paths as such, following the above example:
import os folderpath_read = r'input/images/ct/' filename = os.listdir(path) # pick the first (and only) file in folder filepath_read = os.path.join(folderpath_read, filename) folderpath_write = r'output/images/covid-19-lesion-segmentation/' filepath_write = os.path.join(folderpath_write, filename)
Choosing interfaces determine how you will use evalutils¶
Your choice of interfaces determines how you will use the evalutils template or vice versa. If you wish not to worry about how data is loaded and written, then you could use evalutils simply by filling out the template as given (i.e. option 2 for preparing your code). Consequently, you are implicitly choosing one of the generic in- and output interfaces: Generic Medical Image, Generic Overlay, and/or Results JSON File.
Disclaimer: These generic interfaces are deprecated and may be removed in a future version of the Grand Challenge platform. Instead, we recommend choosing an interface that is specific to your use case. This requires a little bit of extra work though: you have to write your own code to load inputs and write outputs, we describe this as option 3 for preparing your code.
Interfaces can be chosen from a list of existing interfaces, or they can be requested. See the developer docs for an exhaustive list of the types of inputs and outputs that are supported, and instructions on how to format JSON-serializable data such as bounding boxes and polygons.
As you may find, a lot of these interfaces have very specific names, for particular tasks. But even though “Probability COVID-19(Float)” works as an interface for predicting anything that's expressed as a scalar value, we encourage you to request your own interface with a fitting name.
Requesting a new interface option¶
New interfaces can be requested by emailing email@example.com. In this email, please specify the following details for your interface:
- Short description (one or two sentences)
- Kind of data
- Suggestion for read/write path
Take inspiration from the list of existing interfaces, and use a similar style/format to specify the details mentioned above. When the administrators of Grand-Challenge have added your interfaces, they will appear in the list when you create a new algorithm page: