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

Removing outliers from raw signal #521

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/common/nanopolish_fast5_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ raw_table fast5_get_raw_samples(hid_t hdf5_file, fast5_raw_scaling scaling)
herr_t status;
float raw_unit;
raw_table rawtbl = { 0, 0, 0, NULL };

size_t tmp_nsample;

// mostly from scrappie
std::string raw_read_group = fast5_get_raw_read_group(hdf5_file);

Expand Down Expand Up @@ -132,6 +133,19 @@ raw_table fast5_get_raw_samples(hid_t hdf5_file, fast5_raw_scaling scaling)
rawptr[i] = (rawptr[i] + scaling.offset) * raw_unit;
}

// filter the outliers in pA
for (size_t i = nsample-1; i >0 ; i--) {
//filter sample > 200 pA and less than 0 pA
if(rawptr[i]>200 || rawptr[i]<0){
tmp_nsample=tmp_nsample-1;
for (size_t dd=i;dd<nsample;dd++){
rawptr[dd]=rawptr[dd+1];
}
}
}
//to update the value of rawtbl
nsample=tmp_nsample;
rawtbl = (raw_table) { nsample, 0, nsample, rawptr };
cleanup4:
H5Sclose(space);
cleanup3:
Expand Down