@@ -299,6 +299,77 @@ peaks_df = spec.to_dataframe()
299299print (peaks_df.head())
300300```
301301
302+ ### Ion Mobility Support
303+
304+ ` openms-python ` provides comprehensive support for ion mobility data through float data arrays and mobilograms.
305+
306+ #### Float Data Arrays
307+
308+ Spectra can have additional data arrays (e.g., ion mobility values) associated with each peak:
309+
310+ ``` python
311+ from openms_python import Py_MSSpectrum
312+ import pandas as pd
313+ import numpy as np
314+
315+ # Create a spectrum with ion mobility data
316+ df = pd.DataFrame({
317+ ' mz' : [100.0 , 200.0 , 300.0 ],
318+ ' intensity' : [50.0 , 100.0 , 75.0 ],
319+ ' ion_mobility' : [1.5 , 2.3 , 3.1 ]
320+ })
321+
322+ spec = Py_MSSpectrum.from_dataframe(df, retention_time = 60.5 , ms_level = 1 )
323+
324+ # Access ion mobility values
325+ print (spec.ion_mobility) # array([1.5, 2.3, 3.1])
326+
327+ # Set ion mobility values
328+ spec.ion_mobility = np.array([1.6 , 2.4 , 3.2 ])
329+
330+ # Convert to DataFrame with float arrays
331+ df = spec.to_dataframe(include_float_arrays = True )
332+ print (df)
333+ # mz intensity ion_mobility
334+ # 0 100.0 50.0 1.6
335+ # 1 200.0 100.0 2.4
336+ # 2 300.0 75.0 3.2
337+ ```
338+
339+ #### Mobilograms
340+
341+ Mobilograms represent the ion mobility dimension, showing intensity vs. drift time for a specific m/z:
342+
343+ ``` python
344+ from openms_python import Py_Mobilogram
345+ import numpy as np
346+
347+ # Create a mobilogram from arrays
348+ drift_times = np.array([1.0 , 1.5 , 2.0 , 2.5 , 3.0 ])
349+ intensities = np.array([100.0 , 150.0 , 200.0 , 180.0 , 120.0 ])
350+
351+ mob = Py_Mobilogram.from_arrays(drift_times, intensities, mz = 500.0 )
352+
353+ print (f " m/z: { mob.mz} " )
354+ print (f " Points: { len (mob)} " )
355+ print (f " Base peak drift time: { mob.base_peak_drift_time} " )
356+
357+ # Convert to DataFrame
358+ df = mob.to_dataframe()
359+ print (df.head())
360+ # drift_time intensity mz
361+ # 0 1.0 100.0 500.0
362+ # 1 1.5 150.0 500.0
363+ # 2 2.0 200.0 500.0
364+
365+ # Create from DataFrame
366+ df = pd.DataFrame({
367+ ' drift_time' : [1.0 , 2.0 , 3.0 ],
368+ ' intensity' : [50.0 , 100.0 , 75.0 ]
369+ })
370+ mob = Py_Mobilogram.from_dataframe(df, mz = 600.0 )
371+ ```
372+
302373## Workflow helpers
303374
304375` openms_python ` now exposes opinionated utilities that combine the primitive
@@ -696,16 +767,34 @@ plt.show()
696767- ` base_peak_mz ` : m/z of most intense peak
697768- ` base_peak_intensity ` : Intensity of base peak
698769- ` peaks ` : Tuple of (mz_array, intensity_array)
770+ - ` float_data_arrays ` : List of FloatDataArray objects
771+ - ` ion_mobility ` : Ion mobility values as NumPy array
772+ - ` drift_time ` : Spectrum-level drift time value
699773
700774** Methods:**
701775- ` from_dataframe(df, **metadata) ` : Create from DataFrame (class method)
702- - ` to_dataframe() ` : Convert to DataFrame
776+ - ` to_dataframe(include_float_arrays=True ) ` : Convert to DataFrame
703777- ` filter_by_mz(min_mz, max_mz) ` : Filter peaks by m/z
704778- ` filter_by_intensity(min_intensity) ` : Filter peaks by intensity
705779- ` top_n_peaks(n) ` : Keep top N peaks
706780- ` normalize_intensity(max_value) ` : Normalize intensities
707781
708- - ` normalize_intensity(max_value) ` : Normalize intensities
782+ ### Py_Mobilogram
783+
784+ ** Properties:**
785+ - ` name ` : Name of the mobilogram
786+ - ` mz ` : m/z value this mobilogram represents
787+ - ` drift_time ` : Drift time values as NumPy array
788+ - ` intensity ` : Intensity values as NumPy array
789+ - ` peaks ` : Tuple of (drift_time_array, intensity_array)
790+ - ` total_ion_current ` : Sum of intensities
791+ - ` base_peak_drift_time ` : Drift time of most intense point
792+ - ` base_peak_intensity ` : Intensity of base peak
793+
794+ ** Methods:**
795+ - ` from_arrays(drift_time, intensity, mz=None, name=None) ` : Create from arrays (class method)
796+ - ` from_dataframe(df, **metadata) ` : Create from DataFrame (class method)
797+ - ` to_dataframe() ` : Convert to DataFrame
709798
710799### Identifications, ProteinIdentifications & PeptideIdentifications
711800
0 commit comments