Giter Club home page Giter Club logo

Comments (3)

dpodvyaznikov avatar dpodvyaznikov commented on September 7, 2024 1

Hi!

  1. You can drop any channel with drop_channels method of EcgBatch.
  2. In our publication and pipelines we use automated annotations, those with extension pu1.
    Expert annotations are those with q1c and q2c extensions. You can use them by passing corresponding extension to ann_ext parameter of load method, e.g.:
load(fmt='wfdb', components=["signal", "annotation", "meta"], ann_ext='q1c')
  1. If you want to load only a part of the data, you need to create a FilesIndex or DatasetIndex with indices of the files you need.
    For example, if you want to work only with files that have annotation from second expert (files with q2c extension), you can create FilesIndex in a following way:
FilesIndex(path='some_path/qt/*.q2c', no_ext=True)

Here you can find more information about Index objects inbatchflow. Also, you may want to read docstrings for FilesIndex and DatasetIndex methods.

There also is a simple and straightforward way, which is to move files you need to a separate folder and use FilesIndex with corresponding path.

from cardio.

gsm2055 avatar gsm2055 commented on September 7, 2024

If I use this code, I always have 225000 lenth entries. How can I get the only 30 to 50 annotation data contained in q1c?

i am trying to get using csv file. i convert dat to csv . but it's doen't work because when i use csv, Cardio error because it can't find another lead channel..

and.. I found about "drop_channel" method because you told me, but this method requires name and indices
But I don't know how to use only ECG 1-lead using this method. ECG have different names, such as MLII and V5, so how do I use only one channel?

I've been spending about 50 days on this problem. Thanks to you, I think i am closer to the problem. Thank you.

SIGNALS_PATH = "C:/Users/gsm20/Downloads/qt-database-1.0.0"
SIGNALS_MASK = os.path.join(SIGNALS_PATH, "*.q1c")

index = bf.FilesIndex(path=SIGNALS_MASK, no_ext=True, sort=True)
dtst = bf.Dataset(index, batch_class=EcgBatch)
dtst.split()

config_predict = {
'build': False,
'load': {'path': "C:/Users/gsm20/Downloads/train_dill/train_sel&sele_q1c/hmmodel1_q1c.dill"}
}

template_ppl_predict = (
bf.Pipeline()
.init_model("static", HMModel, "HMM", config=config_predict)
.load(fmt="wfdb", components=["signal", "annotation", "meta"], ann_ext="q1c")
.cwt(src="signal", dst="hmm_features", scales=[4,8,16], wavelet="mexh")
.standardize(axis=-1, src="hmm_features", dst="hmm_features")
.predict_model("HMM", make_data=partial(prepare_hmm_input, features="hmm_features", channel_ix=0),
save_to=bf.B("hmm_annotation"), mode='w')
.calc_ecg_parameters(src="hmm_annotation")
.run(batch_size=20, shuffle=False, drop_last=False, n_epochs=1, lazy=True)
)

ppl_predict = (dtst >> template_ppl_predict)

batch = ppl_predict.next_batch()

from cardio.

dpodvyaznikov avatar dpodvyaznikov commented on September 7, 2024

This is how wfdb format works - despite there may be only a few heartbeats annotated, the annotation file is created for the whole signal.

CardIO provides some build-in features and has basic tools that help you build up your own features. It cannot do everything you want out-of-the-box.
If you want to have some fancy processing, e.g. select parts of the signal with regard to annotation, you need to write your own code.

Regarding the drop_channels method: if you don't know channel name, you can simply use indices=0 to drop first channel, indices=1 to drop second, etc. Or you can take a look at the meta component of the batch, it should contain channel names along with other useful information.
There also is keep_channels method that keep only channels which names or indices you've provided.

And I strongly recommend you to thoroughly go through CardIO documentation. It is a good practice to learn about library methods by reading the docs.

I'll close this issue as long as the problem you've described does not have anything to do with CardIO.

from cardio.

Related Issues (20)

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.