CLI Usage
Info
Get basic project info
$ mdai project info --help
Usage: mdai project info [options]
Display project info
Options:
-i, --project-id <id> project id
-h, --help display help for command
Example:
$ mdai project info --project-id MwBeWjNr
Project MwBeWjNr - Test Project
--------------------------------------------------
Description:
Private: YES
Created: 2018-10-07 19:10:16
Updated: 2018-10-07 19:11:39
Get list of project datasets
$ mdai project list-datasets --help
Usage: mdai project list-datasets [options]
List project datasets
Options:
-i, --project-id <id> project id
-h, --help display help for command
Example:
$ mdai project list-datasets --project-id MwBeWjNr
Project MwBeWjNr: Test Project
--------------------------------------------------
Datasets:
ID Name Type Source Created Updated Processing
D_NbrqAB Head CT DICOM upload 2018-10-07 19:11:39 2018-10-07 19:11:39
Get dataset info
$ mdai dataset info --help
Usage: mdai dataset info [options]
Display dataset info
Options:
-i, --dataset-id <id> dataset id
-h, --help display help for command
Example:
$ mdai dataset info --dataset-id D_NbrqAB
Dataset D_NbrqAB: Head CT
--------------------------------------------------
Type DICOM
Source upload
Description
Created 2018-10-07 19:11:39
Updated 2018-10-07 19:14:50
# Studies 1
# Series 1
# Images 11
Creating projects and datasets
Create new project
$ mdai project create --help
Usage: mdai project create [options]
Create new project
Options:
-n, --name <name> project name (use quotes if contains spaces)
-d, --description [description] project description (use quotes if contains spaces)
-h, --help display help for command
Example:
$ mdai project create --name 'New Project' --description 'This is a _markdown_ formatted description.'
Successfully created project New Project [id: L4RJwoNP]
Note
Project name is required, but providing a description is optional.
Create new dataset
$ mdai dataset create --help
Usage: mdai dataset create [options]
Create new dataset in project
Options:
-i, --project-id <id> project id
-s, --source <source> dataset source, one of: [ upload, dicom-push, google-cloud-storage, google-cloud-healthcare-api, amazon-s3 ]
-n, --name <name> dataset name (use quotes if contains spaces)
-d, --description [description] dataset description (use quotes if contains spaces)
-h, --help display help for command
Example:
$ mdai dataset create --project-id L4RJwoNP --source upload --name 'New Dataset' --description 'This is a _markdown_ formatted description.'
Successfully created DICOM dataset New Dataset with upload source [id: D_GmxvgB]
Note
Providing a description is optional.
Clone existing dataset
$ mdai dataset clone --help
Usage: mdai dataset clone [options]
Clone dataset to a different project
Options:
Options:
-i, --dataset-id <datasetid> dataset id to clone from
-p, --project-id <projectid> target project to clone to
-h, --help display help for command
Example:
$ mdai dataset clone --dataset-id D_6BWvjY --project-id VpBQwNA6
Successfully cloned dataset Test_Dataset [id: D_6BWvjY] to Project Test_Project [id: VpBQwNA6]
Loading DICOM resources
Load DICOM into dataset (upload
source only)
$ mdai dataset load --help
Usage: mdai dataset load [options] <pathname>
Load files/folders into dataset (upload source only)
Options:
-i, --dataset-id <id> dataset id
-o, --order-exams-by [ordering] order exams by [ default, patient_id, study_date_time, study_desc, random ] (default: "default")
-h, --help display help for command
Example:
$ mdai dataset load --dataset-id D_GmxvgB dicom_dir
Preparing to upload 'dicom_dir' to DICOM dataset D_GmxvgB...
File count: 11
Total size: 5.52 MB
Uploading:
100% [==================================================] 11/11 [0.0s<0.0s, 478/s]
Completed. No errors.
Done uploading for batch id 1e6ddfed-a32f-4cd4-8113-c683b9122134.
Run `mdai dataset progress -i D_GmxvgB` to track progress.
Load DICOM into dataset (google-cloud-storage
or amazon-s3
source only)
For datasets created with source google-cloud-storage
or amazon-s3
, provide the bucket name (with optional file prefix to filter on).
Note
Bucket permissions must be maintained for the corresponding MD.ai external data service account with at least the Storage Object Viewer role. See the web UI for the service account email, or see the resulting error message for this command when permissions are not present or sufficient.
$ mdai dataset connect --help
Usage: mdai dataset connect [options]
Connect cloud storage bucket into dataset (google-cloud-storage or amazon-s3 source only)
Options:
-i, --dataset-id <id> dataset id
-b, --bucket <bucket> bucket name
-p, --prefix [prefix] folder prefix (optional)
-o, --order-exams-by [ordering] order exams by [ default, patient_id, study_date_time, study_desc, random ] (default: "default")
-h, --help display help for command
Example:
$ mdai dataset connect --dataset-id D_1j4M2B --bucket mdai-test-bucket --prefix test
Dataset D_1j4M2B - New Dataset 2
──────────────────────────────────────────────────
Bucket: mdai-test-bucket
Prefix: test
Order Exams: default
Successfully connected bucket. Run `mdai dataset progress -i D_1j4M2B` to track progress.
Check progress of DICOM processing for dataset
$ mdai dataset progress --help
Usage: mdai dataset progress [options]
Check dataset processing progress
Options:
-i, --dataset-id <id> dataset id
-h, --help display help for command
Example:
$ mdai dataset progress --dataset-id D_NbrqAB
Dataset D_NbrqAB: Head CT
--------------------------------------------------
Type: DICOM
Source: upload
Processing progress for worker batch id 1e6ddfed-a32f-4cd4-8113-c683b9122134
Status FINISHED
Subtask: process uploaded files
# Completed 11
# Remaining 0
# Errors 0
Subtask: generate series thumbnails
# Completed 1
# Remaining 0
# Errors 0
Started 2018-10-07 19:13:36
Elapsed time 1
Percent complete 100%
Deleting DICOM resources
Delete existing dataset
$ mdai dataset delete --help
Usage: mdai dataset delete [options]
Delete dataset
Options:
-i, --dataset-id <id> dataset id
-h, --help display help for command
Example:
$ mdai dataset delete -i D_Zb5Eb4
Dataset D_Zb5Eb4 - VAL
This cannot be undone! Enter the dataset name VAL to comfirm deletion:
VAL
Start deleting dataset VAL
Done deleting dataset VAL
Delete existing studies/series/instances from dataset by UIDs
Delete studies:
$ mdai dataset remove-study --help
Usage: mdai dataset remove-study [options]
Remove studies from dataset by UIDs
Options:
-i, --dataset-id <id> dataset id
-U, --study-uids <uids> StudyInstanceUIDs, separated by commas(no spaces)
-h, --help display help for command
Delete series:
$ mdai dataset remove-series --help
Usage: mdai dataset remove-series [options]
Remove series from dataset by UIDs
Options:
-i, --dataset-id <id> dataset id
-U, --series-uids <uids> SeriesInstanceUIDs, separated by commas(no spaces)
-h, --help display help for command
Delete instances:
$ mdai dataset remove-instance --help
Usage: mdai dataset remove-instance [options]
Remove instances from dataset by UIDs
Options:
-i, --dataset-id <id> dataset id
-U, --instance-uids <uids> SOPInstanceUIDs, separated by commas(no spaces)
-h, --help display help for command
Example:
$ mdai dataset remove-study -i D_vBnWb1 -U 1.2.276.0.7230010.3.1.2.8323329.15697.1531787477.263823,1.2.276.0.7230010.3.1.2.8323329.15695.1531787477.240488
Dataset D_vBnWb1 - TRAIN
Successfully deleted DICOM studies with StudyInstanceUID:
1.2.276.0.7230010.3.1.2.8323329.15697.1531787477.263823
1.2.276.0.7230010.3.1.2.8323329.15695.1531787477.240488
$ mdai dataset remove-series -i D_vBnWb1 -U 1.2.276.0.7230010.3.1.3.8323329.15825.1531787477.370926
Dataset D_vBnWb1 - TRAIN
Successfully deleted DICOM series with SeriesInstanceUID:
1.2.276.0.7230010.3.1.3.8323329.15825.1531787477.370926
$ mdai dataset remove-instance -i D_vBnWb1 -U 1.2.276.0.7230010.3.1.4.8323329.15772.1531787477.330136,1.2.276.0.7230010.3.1.4.8323329.15650.1531787477.198749,1.2.276.0.7230010.3.1.4.8323329.15664.1531787477.222040
Dataset D_vBnWb1 - TRAIN
Successfully deleted DICOM series with SOPInstanceUID:
1.2.276.0.7230010.3.1.4.8323329.15772.1531787477.330136
1.2.276.0.7230010.3.1.4.8323329.15650.1531787477.198749
1.2.276.0.7230010.3.1.4.8323329.15664.1531787477.222040
Models
Check model info
$ mdai model info --help
Usage: mdai model info [options]
Display model info
Options:
-i, --model-id <id> model id
-h, --help display help for command
Example:
$ mdai model info --model-id M_0N3ADm
Model M_0N3ADm - X-Ray Classifier
──────────────────────────────────────────────────
Description: Classifies X-rays as chest or abdomen
Scope: Image
Created: 2022-09-13 11:35:19
Updated: 2022-09-13 11:36:51
Privacy: Private
AutoRun: No
Exportable: No
Cloneable: No
──────────────────────────────────────────────────
Labels With Class Index
──────────────────────────────────────────────────────────────────
class index │ label id │ label name │ label type │ label scope
──────────────────────────────────────────────────────────────────
0 │ L_QRb9NQ │ Abdomen │ Global │ Image
──────────────────────────────────────────────────────────────────
1 │ L_gw3RNg │ Chest │ Global │ Image
──────────────────────────────────────────────────────────────────
──────────────────────────────────────────────────
Versions
─────────────────────────────────────────────────────────────────────────────────────────────────────
# │ id │ Docker Image:Tag │ Created │ Build Status │ Hardware
─────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ 541 │ gcr.io/mdai-models/staging/model-198/v1 │ 2022-09-13 11:35:20 │ Success │ CPU
─────────────────────────────────────────────────────────────────────────────────────────────────────
Clone model
$ mdai model clone --help
Usage: mdai model clone [options]
Clone project models
Options:
--from-project-id <id> original project id
--to-project-ids <ids> target project ids, separated by commas
--from-model-ids [ids] original model ids in original project, separated by commas
--from-domain [domain] original project MD.ai domain (e.g., public.md.ai) - default is mdai config domain
-c, --config-file [path] clone config file (.json or .yaml)
-h, --help display help for command
Example:
$ mdai model clone --from-project-id MmRa7Mqr --to-project-ids 0pqXObNZ
Clone result of project 0pqXObNZ: Clones 3 models into project
Clone models complete!
Update model
$ mdai model set --help
Usage: mdai model set [options]
Update model
Options:
-i, --model-id <id> model id
-n, --model-name [name] model name (use quotes if contains spaces)
-d, --model-description [description] model description (use quotes if contains spaces)
-p, --model-privacy [privacy] configure model privacy (private or public)
-a, --model-autorun-inference [autorun] configure model autorun (y/n, yes or no)
-e, --model-exportable [exportable] configure model exportable (y/n, yes or no)
-c, --model-cloneable [cloneable] configure model cloneable (y/n, yes or no)
-s, --model-clone-scope [scope] model clone scope (SITE_ONLY or ALL_DOMAINS)
-h, --help display help for command
Example:
Change model name:
$ mdai model set --model-id M_7bxME5 --model-name "Demo model"
Successfully set model [id: M_7bxME5] name to be Demo Models
Set model autorun inference to yes:
$ mdai model set --model-id M_7bxME5 --model-autorun-inference yes
Successfully set model [id: M_7bxME5] autorun inference to be yes.
Delete model
$ mdai model delete --help
Usage: mdai model delete [options]
Delete model
Options:
-i, --model-id <id> model id
-h, --help display help for command
Example:
Create model task
$ mdai model create-task --help
Usage: mdai model create-task [options]
Create new model inference task on dataset
Options:
-m, --model-version-id <id> model version id
-i, --dataset-id <id> dataset id
-h, --help display help for command
Example:
$ mdai model create-task --model-version-id 13 --dataset-id D_vbvwom
Successfully created model inference task [Task ID: 190] on dataset Finetuning [Dataset ID: D_vbvwom]
Clone model outputs as annotations
Usage: mdai model clone-output [options]
Clone model outputs as annotations for entire model task
Options:
-i, --model-task-id <id> model task id
-h, --help display help for command
Example:
Project starter packs with models
List available models
Currently supported models for starter packs:
$ mdai model create --list-models
─────────────────────────────────────────────────────────────────────────
name │ description
─────────────────────────────────────────────────────────────────────────
mdai:xray-classifier │ Classifies X-rays as chest or abdomen
─────────────────────────────────────────────────────────────────────────
mdai:lung-segmentation │ Generates segmentation for lungs in xray images
─────────────────────────────────────────────────────────────────────────
mdai:pixel-deid │ Pixel level De-identification
─────────────────────────────────────────────────────────────────────────
Create new project with selected models
$ mdai project create --help
Usage: mdai project create [options]
Create new project
Options:
-n, --name <name> project name (use quotes if contains spaces)
-d, --description [description] project description (use quotes if contains spaces)
-m, --model [name] sample model name
-s, --setting [pathname] project settings
-h, --help display help for comma```
Example:
$ mdai project create --name "Test Project" --model mdai:xray-classifier
Successfully created project Test Project [id: Y2qrE9Nv] and model X-Ray Classifier [id: M_0N3ADm]
Add model to project
$ mdai model create --help
Usage: mdai model create [options]
Create model
Options:
-l, --list-models list available sample models
-i, --project-id <id> project id
-n, --model-name <name> sample model name
-h, --help display help for command
Example:
$ mdai model create --project-id Y2qrE9Nv --model-name mdai:xray-classifier
Successfully created model X-Ray Classifier [id: M_0N3ADm] in project [id: Y2qrE9Nv]
User management
Add users
$ mdai project add-user --help
Usage: mdai project add-user [options]
Add user to project
Options:
-i, --project-id <id> project id
-e, --email <email> user email
-r, --role <role> role of project user [ READER, WRITER, ADMIN ]
-h, --help display help for command
Example:
$ mdai project add-user --project-id maBjAq5 --email user@email.com --role WRITER
Successfully added user U_eMzVMx with WRITER role.
Get list of users
List users in project with their userId, name, email, and permissions.
$ mdai project list-users --help
Usage: mdai project list-users [options]
List project users
Options:
-i, --project-id <id> project id
-j, --json print json object
-h, --help display help for command
Example:
$ mdai project list-users --project-id MwBeWjNr
ID Name Email Role Pending
-----------------------------------------------------------------
U_y01508 Jane Doe jane@md.ai ADMIN No
Get list of assignments
List assignments in project with their userId, name, labelGroupRestriction, and dicomStudyRestriction (exams list).
$ mdai project list-user-assignments --help
Usage: mdai project list-user-assignments [options]
List assignments for project users
Options:
-i, --project-id <id> project id
-j, --json print json object
-h, --help display help for command
Example:
$ mdai project list-user-assignments --project-id MwBeWjNr
userId name labelGroupRestriction dicomStudyRestriction
U_8dX2w8 femur@yopmail.com G_WjoBx1,G_ADkazj D_WmRdXB: 20-30,35,37
U_6vkyr8 ulna@yopmail.com G_A1AXoD None
Add --json
to get output in JSON format:
$ mdai project list-user-assignments --project-id MwBeWjNr --json
"data": [
{
"userId": "U_8dX2w8",
"name": "femur@yopmail.com",
"labelGroupRestriction": [
"G_WjoBx1",
"G_ADkazj"
],
"dicomStudyRestriction": [
{
"dicomDatasetId": "D_WmRdXB",
"dicomDatasetStudyNumbers": "20-30,35,37"
}
]
},
{
"userId": "U_6vkyr8",
"name": "ulna@yopmail.com",
"labelGroupRestriction": ["G_A1AXoD"],
"dicomStudyRestriction": []
}
]
Add/update assignments
$ mdai project update-user-assignment --help
Usage: mdai project update-user-assignment [options]
Update assignments for project users
Options:
-i, --project-id <id> project id
-u, --user-id <id> user id
-d, --dataset-id [id] dataset id
-e, --exams [sequence] assign exams such as 1-3,3-4
-g, --label-group [number(s)] label group sorted index
-h, --help display help for command
This command will assign a range of exams and specific label group to a user programmatically. Users need to be invited to the project first in order to have a userId. Variables needed include
- project-id
- user-id
- dataset-id, if specific exams assigned
- label-group which the number of the label group seen in the UI or 0 if unrestricted
Example (generic):
$ mdai project update-user-assignment --project-id PROJECT_ID --user-id USER_ID --dataset-id DATASET_ID --exams EXAM_NUMBERS --label-group LABEL_GROUP_NUMBER
Successfully updated project user assignment.
Example (specific):
$ mdai project update-user-assignment --project-id maBjAq5 --user-id U_oVjzV --dataset-id D_v0B1N --exams '1-30,47,51-100' --label-group '1,4'
Successfully updated project user assignment.
Remember to set domain and token first.
Note
Users with Admin privileges cannot get assignments if an Admin needs to be given an assignment, invite the user with an additional email address with Read/Write access or the user will have two user_ids, one as an Admin and one as an Annotator.