Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eisen trasformation #3

Closed
bioinfo-dirty-jobs opened this issue Feb 5, 2020 · 4 comments
Closed

Eisen trasformation #3

bioinfo-dirty-jobs opened this issue Feb 5, 2020 · 4 comments

Comments

@bioinfo-dirty-jobs
Copy link

I would like to save my input after normalization and resize as numpy. What is the procedure?
thanks so much!!

@eisen-ai
Copy link
Owner

eisen-ai commented Feb 5, 2020

I don't know if I understand correctly... you would like to dump your data to disk right after it gets transformed (pre-processed).

You can do that by creating a new transformation:

import uuid

class DumpAsNumpy:
    def __init__(self, fields, path):
        self.fields = fields
        self.path = path

   def __call__(self, data):
       for field in self.fields:
           f_name = str(uuid.uuid4())
           numpy.save(data[field], os.path.join(self.path, f_name)

           data[self.field + '_file'] = f_name

        return data

@eisen-ai
Copy link
Owner

eisen-ai commented Feb 5, 2020

Of course this additional transform that dumps data to disk might not have exactly this form. But one instance of this object could be part of the transform chain and therefore save copied of data on the disk.

@bioinfo-dirty-jobs
Copy link
Author

bioinfo-dirty-jobs commented Feb 6, 2020

thanks so much!! I make some confusion I'm interested to use the data normalizated from you tool for extract radiomics. So, I wan to integrate deep learning model with radiomics. I just wondering how to save the data after trasformation on nifty format.

I have tried this code:

tform = Compose([
    read_tform, 
    resample_tform,
    to_numpy_tform,
    crop,
    map_intensities,
    threshold_labels,
    add_channel,
    DumpAsNumpy(fields=['image', 'label'],path="tmp/")
])

dataset = MSDDataset(
    PATH_DATA, 
    NAME_MSD_JSON, 
    'training', 
    transform=tform
)




I miss something .. how can save?

@eisen-ai
Copy link
Owner

you would need to write one more transformation which DumpsAsNifti. Right now DumpAsNumpy will dump files into the ./tmp folder (not into /tmp, because you didn't specify '/tmp' but 'tmp/' instead) in numpy format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants