当前位置:网站首页>Use load_ decathlon_ Datalist (Monai) fast loading JSON data
Use load_ decathlon_ Datalist (Monai) fast loading JSON data
2022-07-07 10:37:00 【Sister Tina】

reflection : When you have a data that contains all the information JSON When you file , How to load into MONAI Inside the frame ?
As shown in the figure , From this json You can know the data in the file label Information , The true meaning of each category . And its mode is CT, Image is 3D And put the training set 、 The address of the image included in the verification set and the test connection is written .
We can feed the data to the model through this file .
stay MONAI It does provide loading json How to format data . Very convenient .
Empathy , We can write our own data as json Format loading .
This tutorial will cover these two contents , If you are interested, let's have a look
load_decathlon_datalist Load data
Where to call ?
from monai.data import load_decathlon_datalist
Function parameter
load_decathlon_datalist(data_list_file_path: PathLike,is_segmentation: bool = True, data_list_key: str = “training”, base_dir: Optional[PathLike] = None,)
Args:
- data_list_file_path: the path to the json file of datalist. Yours json File address
- is_segmentation: whether the datalist is for segmentation task, default is True. Whether it is a split task
- data_list_key: the key to get a list of dictionary to be used, default is “training”. Which data set do you want to load (traning, validation, test), there key It's worth it json The name of the corresponding dataset in the file ( Look at the picture above ).
- base_dir: the base directory of the dataset, if None, use the datalist directory. Home directory of data . You can know from the picture , The address of the data is from imagesTs/imagesTr/labelsTr At the beginning . And the upper level address of these addresses needs to be provided . If you don't fill in , Default and json The files are in the same directory .
Demo sample :
I am here tested.py Load data in the file
from monai.data import load_decathlon_datalist
data_dir = "dataset/dataset.json"
datalist = load_decathlon_datalist(data_dir, True, "training
# datalist = load_decathlon_datalist(data_dir, True, "training", 'dataset') add base_dir

such , accord with MONAI data Your dictionary will be created .
We can see , To have this json file , We can easily create data .
Next , Let's see how to create this json file
Create data json file
from collections import OrderedDict
import json
json_dict = OrderedDict()
json_dict['name'] = "your task"
json_dict['description'] = "btcv yucheng"
json_dict['tensorImageSize'] = "3D"
json_dict['reference'] = "see challenge website"
json_dict['licence'] = "see challenge website"
json_dict['release'] = "0.0"
json_dict['modality'] = {
"0": "CT",
}
json_dict['test'] = [
"imagesTs/img0061.nii.gz",
"imagesTs/img0062.nii.gz",
"imagesTs/img0063.nii.gz",
"imagesTs/img0064.nii.gz",
"imagesTs/img0065.nii.gz",
"imagesTs/img0066.nii.gz"] # Write in the list containing the data .
# What information do you want to save , stay json_dict Add a dictionary data inside
# preservation json
with open(os.path.join(out_base, "dataset.json"), 'w') as f:
json.dump(json_dict, f, indent=4, separators=(',', ': '))
Articles are constantly updated , You can pay attention to the official account of WeChat 【 Medical image AI combat camp 】 Get the latest , The official account of the frontier technology in the field of medical image processing . Stick to the practice , Take you hand in hand to do the project , Play the game , Write a paper . All original articles provide theoretical explanation , Experimental code , experimental data . Only practice can grow faster , Pay attention to our , Learn together ~
I am a Tina, I'll see you on our next blog ~
Working during the day and writing at night , cough
If you think it's well written, finally , Please thumb up , Comment on , Collection . Or three times with one click 
边栏推荐
- Common shortcut keys in IDA
- 基于HPC场景的集群任务调度系统LSF/SGE/Slurm/PBS
- Review of the losers in the postgraduate entrance examination
- 使用U2-Net深层网络实现——证件照生成程序
- ThreadLocal会用可不够
- About hzero resource error (groovy.lang.missingpropertyexception: no such property: weight for class)
- [牛客网刷题 Day5] JZ77 按之字形顺序打印二叉树
- Trajectory planning for multi-robot systems: Methods and applications 综述阅读笔记
- 1324:【例6.6】整数区间
- Study summary of postgraduate entrance examination in November
猜你喜欢

中级软件评测师考什么

ArrayList线程不安全和解决方案

原型与原型链
![1324: [example 6.6] integer interval](/img/5d/29db4d51ec7a2685f8aeffe5be68da.png)
1324: [example 6.6] integer interval
![P1223 queuing for water /1319: [example 6.1] queuing for water](/img/09/29f19b32f0a3c82ddb3c30d5d0b16e.png)
P1223 queuing for water /1319: [example 6.1] queuing for water

字符串格式化

简单易修改的弹框组件

基于HPC场景的集群任务调度系统LSF/SGE/Slurm/PBS

使用Tansformer分割三维腹部多器官--UNETR实战

High number_ Chapter 1 space analytic geometry and vector algebra_ Quantity product of vectors
随机推荐
JMeter about setting thread group and time
【机器学习 03】拉格朗日乘子法
Yarn的基础介绍以及job的提交流程
南航 PA3.1
Experience sharing of software designers preparing for exams
1324:【例6.6】整数区间
IIC基本知识
Study summary of postgraduate entrance examination in July
5个chrome简单实用的日常开发功能详解,赶快解锁让你提升更多效率!
使用 load_decathlon_datalist (MONAI)快速加载JSON数据
Study summary of postgraduate entrance examination in October
How much review time does it usually take to take the intermediate soft exam?
[système recommandé 01] rechub
BigDecimal数值比较
@Configuration, use, principle and precautions of transmission:
Cluster task scheduling system lsf/sge/slurm/pbs based on HPC scenario
The variables or functions declared in the header file cannot be recognized after importing other people's projects and adding the header file
优雅的 Controller 层代码
1323: [example 6.5] activity selection
BigDecimal value comparison