-
Notifications
You must be signed in to change notification settings - Fork 3
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
add calibration #2
base: main
Are you sure you want to change the base?
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
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.
Looks great, great first PR! Just a few notes notes on format.
a, b = symbols('a b') | ||
eq1 = Eq((((t1 * time_res - b)/a) ** 2 - m1) , 0) | ||
eq2 = Eq((((t2 * time_res - b)/a) ** 2 - m2) , 0) | ||
sol = solve((eq1 , eq2) , (a , b)) |
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.
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.
yes I agree. tbh I related on leeat's previous code and didn't solve it myself. would you be ok with selecting the solution that is the closes to the current calibration? something like that:
def calibrate_spectrum(t1 , m1 , t2 , m2 , mass_gain , mass_offset, time_res: float=500e-6):
sign1 = np.array([1 , 1 , -1 , -1])
sign2 = np.array([1 , -1 , 1 , -1])
a = (t1 - t2) * t_res / (sign1 * np.sqrt(m1) + sign2 * np.sqrt(m2))
b = (sign1 * np.sqrt(m2) * t1 + sign2 * np.sqrt(m1) * t2) * t_res / (sign1 * np.sqrt(m2) + sign2 * np.sqrt(m1))
idx = np.argmin((a - mass_gain) ** 2 + (b - mass_offset) ** 2)
return a[idx] , b[idx]
def get_spectra_df(TimeOffset): | ||
data = collections.Counter(TimeOffset) |
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.
TimeOffset
-> time_offset
, just for syntax consistency. Also, I'm adding some docstrings to some of the other functions. Those might already be merged in (can't remember at the moment tbh), but either way, some docstrings here would be handy. For example:
def get_spectra_df(time_offset):
"""Creates formatted pandas dataframe from spectra data
Args:
time_offset (type_of_time_offset (e.g dict, list, etc)):
time offsets
Returns:
pd.DataFrame:
count spectra
"""
# rest of function
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.
sure I'll add them now
def extract_bin_files(data_dir: str, out_dir: str, | ||
include_fovs: Union[List[str], None] = None, | ||
panel: Union[Tuple[float, float], pd.DataFrame] = (-0.3, 0.0), | ||
intensities: Union[bool, List[str]] = False, time_res: float=500e-6, | ||
timeout=100): | ||
timeout=100 , calibration: Union[Tuple[float, float], str] = 'auto'): |
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.
nice! thanks for adding the type signature and giving it a default arg!
@azulaynofar @ngreenwald any plans on continuing development of this PR? |
No description provided.