def filter_battery_off_windows(stream_id: uuid, stream_name: str, main_stream_windows: dict, owner_id: uuid,
                               config: dict, CC_obj: CerebralCortex) -> dict:
    """

    :param stream_id:
    :param stream_name:
    :param main_stream_windows:
    :param owner_id:
    :param config:
    :param CC_obj:
    :return:
    """

    start_time = ""
    end_time = ""
    # load phone battery data
    phone_battery_marker_stream_id = uuid.uuid3(uuid.NAMESPACE_DNS,
                                                str(stream_id + config["stream_name"]["phone_battery"] + owner_id))
    phone_battery_marker_stream = CC_obj.get_datastream(phone_battery_marker_stream_id, data_type=DataSet.ONLY_DATA,
                                                        start_time=start_time,
                                                        end_time=end_time)

    # load sensor battery data
    if stream_name == config["stream_names"]["autosense_ecg"] or stream_name == config["stream_names"]["autosense_rip"]:
        sensor_battery_marker_stream = CC_obj.get_datastream(phone_battery_marker_stream_id,
                                                             data_type=DataSet.ONLY_DATA, start_time=start_time,
                                                             end_time=end_time)
    elif stream_name == config["stream_names"]["motionsense_hrv_accel_right"]:
        sensor_battery_marker_stream = CC_obj.get_datastream(phone_battery_marker_stream_id,
                                                             data_type=DataSet.ONLY_DATA, start_time=start_time,
                                                             end_time=end_time)
    elif stream_name == config["stream_names"]["motionsense_hrv_accel_left"]:
        sensor_battery_marker_stream = CC_obj.get_datastream(phone_battery_marker_stream_id,
                                                             data_type=DataSet.ONLY_DATA, start_time=start_time,
                                                             end_time=end_time)
    battery_marker = 0
    results = None
    for key, data in main_stream_windows.items():
        for phone_key, phone_data in phone_battery_marker_stream.items():
            if phone_key.start_time <= key.start_time and phone_key.end_time >= key.end_time:
                battery_marker = 1
        for sensor_key, sensor_data in sensor_battery_marker_stream.items():
            if sensor_key.start_time <= key.start_time and sensor_key.end_time >= key.end_time:
                battery_marker = 1

        if battery_marker != 1:
            results[key] = data
    return results
def phone_screen_touch_marker(raw_stream_id: uuid,
                              raw_stream_name: str,
                              owner_id,
                              dd_stream_name,
                              CC: CerebralCortex,
                              config: dict,
                              start_time=None,
                              end_time=None):
    """
    This is not part of core data diagnostic suite.
    It only calculates how many screen touches are there.
    :param raw_stream_id:
    :param CC:
    :param config:
    """

    try:
        # using stream_id, data-diagnostic-stream-id, and owner id to generate a unique stream ID for battery-marker
        screen_touch_stream_id = uuid.uuid3(
            uuid.NAMESPACE_DNS,
            str(raw_stream_id + dd_stream_name + owner_id +
                "mobile phone screen touch marker"))

        stream_days = get_stream_days(raw_stream_id, screen_touch_stream_id,
                                      CC)

        for day in stream_days:
            stream = CC.get_datastream(raw_stream_id,
                                       data_type=DataSet.COMPLETE,
                                       day=day,
                                       start_time=start_time,
                                       end_time=end_time)
            if len(stream.data) > 0:
                windowed_data = window(stream.data,
                                       config['general']['window_size'], True)
                results = process_windows(windowed_data)

                merged_windows = merge_consective_windows(results)
                if len(merged_windows) > 0:
                    input_streams = [{
                        "owner_id": owner_id,
                        "id": str(raw_stream_id),
                        "name": raw_stream_name
                    }]
                    output_stream = {
                        "id": screen_touch_stream_id,
                        "name": dd_stream_name,
                        "algo_type":
                        config["algo_type"]["app_availability_marker"]
                    }
                    metadata = get_metadata(dd_stream_name, input_streams,
                                            config)
                    store(merged_windows, input_streams, output_stream,
                          metadata, CC, config)

    except Exception as e:
        print(e)