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

Adds total spectra extraction #35

Merged
merged 14 commits into from
Oct 8, 2024
Merged

Adds total spectra extraction #35

merged 14 commits into from
Oct 8, 2024

Conversation

ackagel
Copy link
Collaborator

@ackagel ackagel commented Jun 1, 2022

Adds total spectra extraction. This will help validate that ionpath's default mass calibration parameters are within tolerance.

@ackagel ackagel requested a review from ngreenwald June 1, 2022 19:29
Copy link
Member

@ngreenwald ngreenwald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still failing

@alex-l-kong
Copy link
Contributor

Do we plan on further developing this PR? If so, I can take over.

@ngreenwald
Copy link
Member

I think @jranek maybe needed something similar, and Avery might have gone to office hours for something related? If no one needs it though, fine to close this branch

@alex-l-kong
Copy link
Contributor

@jranek just wanted to get some ideas from you regarding this setup. Adam used a slightly different setup to start off with. I modified it so instead of taking the total mass spectra across all pixels, it would delineate the spectra across individual pixels.

Copy link

@jranek jranek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @alex-l-kong, I went to test these files to see if it gives a per-pixel spectra output; however, it immediately crashes due to memory error regardless of (1) the bin file size, (2) the number of FOVs I pass through, or (3) the spectra range specified in the panel df

@jranek
Copy link

jranek commented Nov 2, 2023

@alex-l-kong this looks great!! As a suggestion, I think it's worth converting the tof ranges back to m/z for ease of plotting the spectra. For example,

def _tof2mass(tof_range: np.ndarray, mass_offset: float, mass_gain: float,
              time_res: float) -> np.ndarray:
    """Convert array of time of flight values to equivalent m/z

    Args:
        toff_arr (array_like):
            Array of time of flight values
        mass_offset (float):
            Mass offset for parabolic transformation
        mass_gain (float):
            Mass gain for parabolic transformation
        time_res (float):
            Time resolution for scaling parabolic transformation

    Returns:
        array_like:
            Array of m/z values; indicies paried to `toff_arr`
    """
    return (((time_res * tof_range) - mass_offset) / mass_gain)**2

The mass range interval can be in the return statement or appended as metadata in the fov_files dictionary. Also, it might be worth renaming fov_files in the return to be a little more descriptive of the metadata within the dictionary, or just providing a little more detail in the docstring!

@alex-l-kong
Copy link
Contributor

@alex-l-kong this looks great!! As a suggestion, I think it's worth converting the tof ranges back to m/z for ease of plotting the spectra. For example,

def _tof2mass(tof_range: np.ndarray, mass_offset: float, mass_gain: float,
              time_res: float) -> np.ndarray:
    """Convert array of time of flight values to equivalent m/z

    Args:
        toff_arr (array_like):
            Array of time of flight values
        mass_offset (float):
            Mass offset for parabolic transformation
        mass_gain (float):
            Mass gain for parabolic transformation
        time_res (float):
            Time resolution for scaling parabolic transformation

    Returns:
        array_like:
            Array of m/z values; indicies paried to `toff_arr`
    """
    return (((time_res * tof_range) - mass_offset) / mass_gain)**2

The mass range interval can be in the return statement or appended as metadata in the fov_files dictionary. Also, it might be worth renaming fov_files in the return to be a little more descriptive of the metadata within the dictionary, or just providing a little more detail in the docstring!

Changes are added. Lmk how this new version looks @jranek.

Copy link

@jranek jranek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome!!

@alex-l-kong alex-l-kong merged commit 5b81528 into main Oct 8, 2024
17 of 19 checks passed
@alex-l-kong alex-l-kong deleted the total-spectra branch October 8, 2024 22:16
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

Successfully merging this pull request may close these issues.

4 participants