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

how to predict with .edf file? #39

Closed
Hunter0904 opened this issue Jul 22, 2020 · 6 comments
Closed

how to predict with .edf file? #39

Hunter0904 opened this issue Jul 22, 2020 · 6 comments
Assignees

Comments

@Hunter0904
Copy link

Dear all:
I have train a model with /example/Getting_started.jupyter
it's worked with .hea file
and it can predict hea file
but how to read .edf file
when I change lod .head file to .edf file
code:
index = bf.FilesIndex(path="../cardio/tests/data/sample.edf", no_ext=True, sort=True)
eds = bf.Dataset(index, batch_class=EcgBatch)
batch = eds.next_batch(batch_size=2)
batch_with_data = batch.load(fmt="edf", components=["signal", "meta"])

from cardio.pipelines import dirichlet_predict_pipeline
model_path = "af_model_dump"
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.7, allow_growth=True)
pipeline = dirichlet_predict_pipeline(model_path, gpu_options=gpu_options)
res = (eds >> pipeline).run()
pred = res.get_variable("predictions_list")

I get problem :
/usr/local/lib/python3.6/dist-packages/cardio/core/ecg_batch.py in _reraise_exceptions(self, results)
197 if bf.any_action_failed(results):
198 all_errors = self.get_errors(results)
--> 199 raise RuntimeError("Cannot assemble the batch", all_errors)
200
201 @staticmethod

RuntimeError: ('Cannot assemble the batch', [FileNotFoundError(2, 'No such file or directory')])

Plz help me~~
thanks a lot

@dpodvyaznikov
Copy link
Member

Hi, @Hunter0904 !

Predefined pipelines that you are using were designed to demonstrate how the library works on two specific tasks with specific datasets. If you take a look at dirichlet_predict_pipeline's source code, you'd see that fmt parameter in load action is set to 'wfdb', because the pipeline was developed to work with PhysioNet2017 Challenge data.

You can use our pipelines as an example to develop those suited for your needs. E.g., to solve your current issue you can just replace 'wfdb' to 'edf' in dirichlet_predict_pipeline.

@Hunter0904
Copy link
Author

@dpodvyaznikov Thank for your answer.
But I don't have enough data to train new 'edf' model.
Is there a way to change the 'edf' file to 'wfdb' format ?
then I can use the same model to predict.

@dpodvyaznikov
Copy link
Member

You still can use the model you've trained with dirichlet_train_pipeline.
The issue is in the way dirichlet_predict_pipeline tries to load the data. Since it has fmt='wfdb' in its load action, it tries to open file sample.hea instead of sample.edf. Since there is no such file, you get the error.
As I've said before, if you change fmt parameter to 'edf' in source code of dirichlet_predict_pipeline, you'll be able to run inference on edf files. Or you can make it a function argument and pass it directly when creatin pipeline.

@Hunter0904
Copy link
Author

I will try it ~
very appreciate~thanks a lot

@dpodvyaznikov
Copy link
Member

I'll close this issue for now.

@Hunter0904
Copy link
Author

I had tried this. It's worked.
thanks a lot~~~

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

3 participants