def test_combine_fooofs(tfm, tfg): tfm2 = tfm.copy() tfm3 = tfm.copy() tfg2 = tfg.copy() tfg3 = tfg.copy() # Check combining 2 FOOOFs nfg1 = combine_fooofs([tfm, tfm2]) assert nfg1 assert len(nfg1) == 2 assert compare_info([nfg1, tfm], 'settings') assert nfg1.group_results[0] == tfm.get_results() assert nfg1.group_results[-1] == tfm2.get_results() # Check combining 3 FOOOFs nfg2 = combine_fooofs([tfm, tfm2, tfm3]) assert nfg2 assert len(nfg2) == 3 assert compare_info([nfg2, tfm], 'settings') assert nfg2.group_results[0] == tfm.get_results() assert nfg2.group_results[-1] == tfm3.get_results() # Check combining 2 FOOOFGroups nfg3 = combine_fooofs([tfg, tfg2]) assert nfg3 assert len(nfg3) == len(tfg) + len(tfg2) assert compare_info([nfg3, tfg, tfg2], 'settings') assert nfg3.group_results[0] == tfg.group_results[0] assert nfg3.group_results[-1] == tfg2.group_results[-1] # Check combining 3 FOOOFGroups nfg4 = combine_fooofs([tfg, tfg2, tfg3]) assert nfg4 assert len(nfg4) == len(tfg) + len(tfg2) + len(tfg3) assert compare_info([nfg4, tfg, tfg2, tfg3], 'settings') assert nfg4.group_results[0] == tfg.group_results[0] assert nfg4.group_results[-1] == tfg3.group_results[-1] # Check combining a mixture of FOOOF & FOOOFGroup nfg5 = combine_fooofs([tfg, tfm, tfg2, tfm2]) assert nfg5 assert len(nfg5) == len(tfg) + 1 + len(tfg2) + 1 assert compare_info([nfg5, tfg, tfm, tfg2, tfm2], 'settings') assert nfg5.group_results[0] == tfg.group_results[0] assert nfg5.group_results[-1] == tfm2.get_results() # Check combining objects with no data tfm2._reset_data_results(False, True, True) tfg2._reset_data_results(False, True, True, True) nfg6 = combine_fooofs([tfm2, tfg2]) assert len(nfg6) == 1 + len(tfg2) assert nfg6.power_spectra is None
def test_compare_info(tfm, tfg): for f_obj in [tfm, tfg]: f_obj2 = f_obj.copy() assert compare_info([f_obj, f_obj2], 'settings') f_obj2.peak_width_limits = [2, 4] f_obj2._reset_internal_settings() assert not compare_info([f_obj, f_obj2], 'settings') assert compare_info([f_obj, f_obj2], 'meta_data') f_obj2.freq_range = [5, 25] assert not compare_info([f_obj, f_obj2], 'meta_data')
# Note that these functions that manipulate FOOOF objects typically do more than just # copy results data - they also check and manage settings and meta-data of objects. # # For example, combining FOOOF objects returns a new FOOOFGroup object with the same settings. # # We can see this by using the :func:`~.compare_info` function to compare # the settings between FOOOF objects. # # You can also use this function if you wish to compare FOOOF objects to ensure that # you are comparing model results that were fit with equivalent settings. # ################################################################################################### # Compare defined settings across FOOOF objects compare_info([fm1, fg], 'settings') ################################################################################################### # Sub-Select from FOOOFGroup # -------------------------- # # When you have a :class:`~fooof.FOOOFGroup` object, you may also want to sub-select # a group of models. # # Example use cases for this could be: # # - you want to sub-select models that meet some kind of goodness-of-fit criterion # - you want to examine a subset of model reflect, for example, particular channels or trials # # To do so, we can use the :func:`~fooof.FOOOFGroup.get_group` method of the FOOOFGroup object. # This method takes in an input specifying which indices to sub-select, and returns a