Ejemplo n.º 1
0
    def run(self):
        params = self.parameters
        for index_i, item_i in enumerate(params):
            export_name, file_stat = item_i
            export_folder = os.path.dirname(file_stat[0][0])

            if export_name[-3:] != '.00':
                export_name += '.00'
            output_file = open(os.path.join(export_folder, export_name), 'wb')
            for index_j, item_j in enumerate(file_stat):
                file_path, dt_start, dt_stop = item_j

                bin_data = BinaryFile()
                bin_data.path = file_path
                bin_data.use_avg_values = False

                if index_j == 0:
                    output_file.write(bin_data.main_header.get_binary_format())
                    for k in range(3):
                        output_file.write(
                            bin_data.get_channel_header(k).get_binary_format())
                    # channel_headers_hole = np.array([0] * 54, dtype=np.int32)
                    # channel_headers_hole.tofile(output_file)
                signal = bin_data.signals
                signal.astype(np.int32).tofile(output_file)
                self.finished_part_stitching.emit(
                    (index_j + 1) / len(file_stat) * 100)
            self.finished_file.emit((index_i + 1) / len(params) * 100)
Ejemplo n.º 2
0
folder = '/media/michael/Садыков_РР/mihael'

for root, folders, files in os.walk(folder):
    for file in files:
        name, extension = file.split('.')
        if extension not in ('00', 'xx'):
            continue
        print(name)
        bin_data = BinaryFile()
        bin_data.path = os.path.join(root, file)
        bin_data.record_type = 'ZXY'
        signals = bin_data.ordered_signal_by_components

        main_header = bin_data.main_header
        channel_header_a = bin_data.get_channel_header(channel_index=0)
        channel_header_b = bin_data.get_channel_header(channel_index=1)
        channel_header_c = bin_data.get_channel_header(channel_index=2)

        for i in range(3):
            detrend_signal = detrend(signal=signals[:, i],
                                     frequency=bin_data.signal_frequency,
                                     edge_frequency=2)
            signals[:, i] = detrend_signal[:signals[:, i].shape[0]]

        output_file_path = os.path.join(
            root, name + '_detrend.' + bin_data.extension)
        output_file = open(output_file_path, 'wb')
        output_file.write(main_header.get_binary_format())
        output_file.write(channel_header_a.get_binary_format())
        output_file.write(channel_header_b.get_binary_format())
Ejemplo n.º 3
0
files = os.listdir('/media/michael/Transcend/1')

export_folder = '/media/michael/Data/TEMP'
for file in files:
    if file in os.listdir(export_folder):
        continue
    path = os.path.join('/media/michael/Transcend/1', file)
    bin_data = BinaryFile()
    bin_data.path = path
    signals = bin_data.signals

    main_header = bin_data.main_header
    bin_main_h = main_header.get_binary_format()

    ch_header = [
        bin_data.get_channel_header(channel_index=0),
        bin_data.get_channel_header(channel_index=1),
        bin_data.get_channel_header(channel_index=2)
    ]

    bin_channels = [x.get_binary_format() for x in ch_header]

    export_path = os.path.join(export_folder, file)
    with open(export_path, 'wb') as handle:
        handle.write(bin_main_h)
        handle.write(bin_channels[0])
        handle.write(bin_channels[1])
        handle.write(bin_channels[2])
        signals.astype(np.int32).tofile(handle)
    print(f'File {file} done')