Convert JSON
1. Download JSON
- Option 1: Download JSON file directly from the UI using the
Export
tab and drag JSON file into working director - Option 2: Use mdai library to download JSON
Create Client
Example output
Download annotations
Example output
2. JSON to Dataframe
Copy the downloaded file name from the output above or from your downloaded JSON file. (if errors occur, try downloading annotations outside of your firewall)
3. Conversions
Bounding box
Extract box data dictionary items
Example output
Derive additional box data
Now lets get the box center, area, and bottom left corner
Example output
Formatting examples
Detectron 2
Detectron 2 expects bbox coordinates to be in the format of [x_upper_left, y_upper_left, x_lower_right, y_lower_right]. Be mindful of the need to scale the annotation data if image is scaled
Fastai
Fastai expects bbox coordinates to be in the format of (y_upper_left, x_upper_left, y_lower_right, x_lower_right) with the origin being in the upper left hand corner of the image. Remember to scale annotations if images are scaled
Freeform and polygon
Filter for freeform and polygon
Get box bounding the vertices
Example output
Longest diameter
Get longest diameter of a shape in mm. Pixel spacing is obtained using the pydicom library and the PixelSpacing tag
Example
Mask
Convert MD.ai annotation to mask
Function to load a single mask instance from one row of annotation data. This will turn one box, free form, polygon, etc into a binary mask sized to the corresponding image.