remove time info

Platform macOS-13.3-arm64-arm-64bit

Python 3.12.3 (v3.12.3:f6650f9ad7, Apr 9 2024, 08:18:47) [Clang 13.0.0 (clang-1300.0.29.30)]

Executable /usr/local/bin/python3

CPU Apple M2 Max (12 cores)

Memory 64.0 GiB

Dear all

I am trying to remove time of acquisition for eeg data

Code 

##################

import mne

from mne.io import read_raw_edf

from mne.export

import export_raw file_name = ‘d001.edf’

Replace with your EDF file path raw = read_raw_edf(file_name)

# Define a new datetime object in UTC

# Example: January 1st, 2000 at 12:00:00 PM UTC

new_date_utc = ‘2000-01-01 00:00:00 UTC’

rawrewrite=raw.copy()

print(rawrewrite.info)”

# Set the new measurement date

rawrewrite.set_meas_date(new_date_utc)

print(‘’) print(‘Original Time Info Removed’) print(‘’) print(rawrewrite.info)

# Define the output filename with the .edf extension

output_fname = ‘d001nodate.edf’

# Export the raw object to EDF format

# The fmt=‘edf’ parameter ensures the correct format is used

# You can also specify the filename with a .edf extension and set fmt=‘auto’

export_raw(output_fname, rawrewrite, fmt=‘edf’, overwrite=True)

############################

See code above i try to modify meas_date to 2000-01-01 00:00:00 UTC

when i recheck the data info it is unspecified

but if i write and read the modified data, the date is 1985-01-01 00:00:00 UTC

Thank you

Anne-Cecile Lesage

Research scientist UTMB

:fountain_pen: To get the correct formatting, paste your Python code, then select it, and click on the Preformatted text toolbar button.

:no_mobile_phones: Please avoid sharing screenshots of code and error messages! Screenshots are difficult to work with especially on mobile devices; they don’t allow others to copy code and other text; and they don’t show up in the search.

:backhand_index_pointing_right: :backhand_index_pointing_right: :backhand_index_pointing_right: Please edit or remove the above text before submitting your posting. :backhand_index_pointing_left: :backhand_index_pointing_left: :backhand_index_pointing_left:

Hello,

Strings as measurement dates should have the following format "%Y-%m-%d %H:%M:%S.%f", where %f is microsecond precision (i.e., 6 decimal places), e.g., "2000-01-01 00:00:00.000000".

Because your string does not match this format, you get the "unspecified" measurement date. Then when you read the Raw object back in, this "unspecified" date gets replaced by a default (1985) value.

If you switch to "2000-01-01 00:00:00.000000", you will see the date get set properly and preserved on reading back in.

And in future, please format the example code, it makes it much easier for us to read.

1 Like

thank you Thomas

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.