-
Notifications
You must be signed in to change notification settings - Fork 40
Fix min and max mz filtering in cut_mz_domain_noise #13
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,20 +120,20 @@ def cut_mz_domain_noise(self): | |
|
|
||
| if max_mz_noise > max_mz_whole_ms: | ||
| max_mz_noise = max_mz_whole_ms | ||
|
|
||
| #print(min_mz_noise, max_mz_noise) | ||
| low_mz_index = (where(self.mz_exp_profile >= min_mz_noise)[0][0]) | ||
| #print(self.mz_exp_profile[low_mz_index]) | ||
| # low_mz_index = (argmax(self.mz_exp_profile <= min_mz_noise)) | ||
|
|
||
| high_mz_index = (where(self.mz_exp_profile <= max_mz_noise)[-1][-1]) | ||
|
|
||
| #the following indexing relies on mz_exp_profile being ordered high mz to low mz | ||
| low_mz_index = (where(self.mz_exp_profile >= min_mz_noise)[-1][-1]) | ||
| #print(self.mz_exp_profile[low_mz_index]) | ||
| #low_mz_index = (argmax(self.mz_exp_profile <= min_mz_noise)) | ||
|
|
||
| high_mz_index = (where(self.mz_exp_profile <= max_mz_noise)[0][0]) | ||
| #print(self.mz_exp_profile[high_mz_index]) | ||
| #high_mz_index = (argmax(self.mz_exp_profile <= max_mz_noise)) | ||
|
|
||
| if high_mz_index > low_mz_index: | ||
| # pyplot.plot(self.mz_exp_profile[low_mz_index:high_mz_index], self.abundance_profile[low_mz_index:high_mz_index]) | ||
| # pyplot.show() | ||
| return self.mz_exp_profile[high_mz_index:low_mz_index], self.abundance_profile[low_mz_index:high_mz_index] | ||
| return self.mz_exp_profile[low_mz_index:high_mz_index], self.abundance_profile[low_mz_index:high_mz_index] | ||
|
Comment on lines
133
to
+136
|
||
| else: | ||
| # pyplot.plot(self.mz_exp_profile[high_mz_index:low_mz_index], self.abundance_profile[high_mz_index:low_mz_index]) | ||
| # pyplot.show() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
where(...)[-1][-1]/[0][0]selection assumesmz_exp_profileis sorted high→low. Ifmz_exp_profileis low→high (which theif high_mz_index > low_mz_indexbranch suggests is possible, and can happen for array-based inputs),low_mz_indexbecomes the last element and the slice includes values outside[min_mz_noise, max_mz_noise], so min/max filtering breaks again. Consider making the index selection order-independent, e.g., build a boolean mask for(mz>=min)&(mz<=max)and slice usingmin(idx):max(idx)+1, which also lets you drop the order-dependent comment and theif/else.