Coder Social home page Coder Social logo

Comments (9)

mengluffy avatar mengluffy commented on June 17, 2024

yes , me too. I don't know how to options folder, my nii.gz file all in one folder.

from cnn-ms-lesion-segmentation.

sergivalverde avatar sergivalverde commented on June 17, 2024

Hi @masmai @mengluffy

Following the provided example notebook, each training image is inside a folder:

train_folder = '/mnt/DATA/w/CNN/images/train_images'
train_x_data = {}
train_y_data = {}

# TRAIN X DATA
train_x_data['im1'] = {'T1': os.path.join(train_folder,'im1', 'T1.nii.gz'), 
                       'FLAIR': os.path.join(train_folder,'im1', 'T1.nii.gz')}
train_x_data['im2'] = {'T1': os.path.join(train_folder,'im2', 'T1.nii.gz'), 
                       'FLAIR': os.path.join(train_folder,'im2', 'T1.nii.gz')}
train_x_data['im3'] = {'T1': os.path.join(train_folder,'im3', 'T1.nii.gz'), 
                       'FLAIR': os.path.join(train_folder,'im3', 'T1.nii.gz')}

# TRAIN LABELS 
train_y_data['im1'] = os.path.join(train_folder,'im1', 'lesion_bin.nii.gz')
train_y_data['im2'] = os.path.join(train_folder,'im2', 'lesion_bin.nii.gz')
train_y_data['im3'] = os.path.join(train_folder,'im3', 'lesion_bin.nii.gz')

So, your input folder should be something like:

[training_folder] 
                        [im1 folder]
                                            flair.nii.gz
                                            t1.nii.gz
                                            lesion_bin.nii.gz
                        [im2 folder]
                                            flair.nii.gz
                                            t1.nii.gz
                                            lesion_bin.nii.gz
                        
                       ...
                       
                        [im_n folder]
                                           flair.nii.gz
                                           t1.nii.gz
                                           lesion_bin.nii.gz

where image folders names are used as keys in the dictionary train_x_data

Take into account that you can call the training images differently simply filling the dictionary in other ways. For instance, if you have all training mages inside the same folder, then:

train_folder = '/path/to/training/images/'
train_x_data = {}
train_y_data = {}

# TRAIN X DATA
train_x_data['im1_id'] = {'T1': os.path.join(train_folder, 'T1_im1.nii.gz'), 
                       'FLAIR': os.path.join(train_folder, 'FLAIR_im1.nii.gz')}
train_x_data['im2_id'] = {'T1': os.path.join(train_folder, 'T1_im2.nii.gz'), 
                       'FLAIR': os.path.join(train_folder, 'FLAIR_im2.nii.gz')}
train_x_data['im3_id'] = {'T1': os.path.join(train_folder, 'T1_im3.nii.gz'), 
                       'FLAIR': os.path.join(train_folder,  'FLAIR_im3.nii.gz')}

# TRAIN LABELS 
train_y_data['im1_id'] = os.path.join(train_folder, 'lesion_bin_im1.nii.gz')
train_y_data['im2_id'] = os.path.join(train_folder,'lesion_bin_im2.nii.gz')
train_y_data['im3_id'] = os.path.join(train_folder,'lesion_bin_im3.nii.gz')

hope it helps,

from cnn-ms-lesion-segmentation.

masmai avatar masmai commented on June 17, 2024

I'm sorry to make you misunderstand. Actually, I've already put "traning_folder" Follow the instructions.
But I do not know where to find Traning images?

from cnn-ms-lesion-segmentation.

sergivalverde avatar sergivalverde commented on June 17, 2024

I'm sorry but the repository do not provide training images.

from cnn-ms-lesion-segmentation.

mengluffy avatar mengluffy commented on June 17, 2024

I change folder in my computer, don't in code, than have another error
Traceback (most recent call last):
File "/home/kmust/cnnsg/train_leave_one_out.py", line 79, in
model = train_cascaded_model(model, train_x_data, train_y_data, options)
File "/home/kmust/cnnsg/base.py", line 42, in train_cascaded_model
X, Y = load_training_data(train_x_data, train_y_data, options)
File "/home/kmust/cnnsg/base.py", line 140, in load_training_data
y_data = [train_y_data[s] for s in scans]
KeyError: 'im1'

from cnn-ms-lesion-segmentation.

sergivalverde avatar sergivalverde commented on June 17, 2024

And what's the question?

It's obvious that something is wrong with the dictionary, isn't it? The dictionary keys should correspond to the image folder names. Just with this information is very difficult to help:
Look at this:

https://github.com/sergivalverde/cnn-ms-lesion-segmentation/blob/master/train_leave_one_out.py#L44

from cnn-ms-lesion-segmentation.

melrobin avatar melrobin commented on June 17, 2024

It appears that the data is not in .nii.gz format, but it seems in NRRD. Can someone confirm this?

from cnn-ms-lesion-segmentation.

sergivalverde avatar sergivalverde commented on June 17, 2024

from cnn-ms-lesion-segmentation.

melrobin avatar melrobin commented on June 17, 2024

OK, thanks! I was able to perform the conversion.

from cnn-ms-lesion-segmentation.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.