open-ephys / open-ephys-matlab-tools

Matlab code for interacting with the Open Ephys GUI
MIT License
11 stars 8 forks source link

Error using containers.Map/subsref #5

Closed shirquinn closed 1 year ago

shirquinn commented 1 year ago

Hi I'm recording with OE gui v0.6.3 when tryin to load a recording with 2 record nodes i get this error:

>> session = Session('D:\Jan_2023\recordings\WT\C3669\2023-02-01_14-21-27')
Error using containers.Map/subsref
The specified key is not present in this container.
Error in BinaryRecording/loadContinuous (line 93)
                stream.metadata.startTimestamp = syncMessages(streamKey);
Error in BinaryRecording (line 40)
            self = self.loadContinuous();
Error in BinaryRecording.detectRecordings (line 254)
                    recordings{end+1} = BinaryRecording(recordingDirectories{recIdx}, expIdx, recIdx);
Error in RecordNode/detectRecordings (line 94)
                self.recordings = BinaryRecording.detectRecordings(self.directory);
Error in RecordNode (line 71)
            self.detectRecordings();
Error in Session/detectRecordNodes (line 68)
                self.recordNodes{end+1} = RecordNode(paths{i});
Error in Session (line 59)
            self.detectRecordNodes(); 
93                  stream.metadata.startTimestamp = syncMessages(streamKey);
medengineer commented 1 year ago

Hi

Can you paste the streamKey value that is causing this error by adding 'streamKey' without a ';' right above line 93 in BinaryRecording? Can you also attach the sync_messages.txt file located in C3669\2023-02-01_14-21-27\recording1\experiment1?

Thanks!

shirquinn commented 1 year ago

I guess that in this version the sync message is different than previous ones This is the sync message: Software Time (milliseconds since midnight Jan 1st 1970 UTC): 1675336627449 Start Time for Acquisition Board (100) - Rhythm Data @ 30000 Hz: 0

this is how the raw messages looks like:

rawMessages =
  3×1 cell array
    {'Software Time (milliseconds since midnight Jan 1st 1970 UTC): 1675336627449'}
    {'Start Time for Acquisition Board (100) - Rhythm Data @ 30000 Hz: 0'         }
    {0×0 char                                                                     }

causing the error:

 function syncMessages = loadSyncMessages(self)

            syncMessages = containers.Map();

            rawMessages = splitlines(fileread(fullfile(self.directory, 'sync_messages.txt')));

            for i = 1:length(rawMessages)-1

                message = strsplit(rawMessages{i});
                data = strsplit(message{end}, "@");
                sampleFrequency = str2num(data{2}(1:end-2)); %Removes trailing 'Hz'
                startTimestamp = str2num(data{1});
                if message{1} == "Software" %found software time
                    syncMessages("Software") = [startTimestamp, sampleFrequency];
                else %extract unique processor id
                    n = 1; while message{n} ~= "Id:" n = n + 1; end
                    syncMessages(strcat(message{n+1}, ".", message{n+3})) = startTimestamp;
                end

            end
ShaynDoe commented 1 year ago

Hello, was this ever resolved? I am facing the same issue.

medengineer commented 1 year ago

Hi,

Can you check if the version found at the link below works for you?

https://www.dropbox.com/s/1ox5hof24p0johs/open_ephys-matlab-tools-10-4.zip?dl=0

ShaynDoe commented 1 year ago

@medengineer Yes, this version works well for me! Can I ask - what was the problem? Thanks for the prompt help!

medengineer commented 1 year ago

It’s an issue with using the sync_messages.txt file to load stream start times due to the format of a few processor names. There’s a more consistent way to achieve the same thing I will add in the next update.

shirquinn commented 1 year ago

@medengineer i have tried your fix and i get this error:

session = Session(directory)
[DEBUG] Searching directory:  D:\Jan_2023\recordings\WT\C3780\2023-03-16_13-26-53 
[DEBUG] Found recording format: Binary 
[DEBUG] Searching for recordings... 
[DEBUG] Loading continuous data... 
[DEBUG] Loading sync messages... 
[DEBUG] Finished loading sync messages! 
[DEBUG] Loading data from directory:  D:\Jan_2023\recordings\WT\C3780\2023-03-16_13-26-53\Record Node 113\experiment1\recording1\continuous\Acquisition_Board-100.Rhythm Data\ 
[DEBUG] Searching for start timestamp for stream:  
[DEBUG]      Acquisition_Board-100.Rhythm Data 
[DEBUG] Available streams:  
[DEBUG]      Acquisition_Board-100.Rhythm Data 
[DEBUG]      Software 
[DEBUG] Finished loading continuous data! 
[DEBUG] Loading event data! 
[DEBUG] Finished loading event data! 
[DEBUG] Loading spike data! 
[DEBUG] Finished loading spike data! 
[DEBUG] Finished searching for recordings! 
[DEBUG] Detected 1 recordings. 
[DEBUG] Found recording format: Binary 
[DEBUG] Searching for recordings... 
[DEBUG] Loading continuous data... 
[DEBUG] Loading sync messages... 
[DEBUG] Finished loading sync messages! 
[DEBUG] Loading data from directory:  D:\Jan_2023\recordings\WT\C3780\2023-03-16_13-26-53\Record Node 114\experiment1\recording1\continuous\Acquisition_Board-100.Rhythm Data-A\ 
[DEBUG] Searching for start timestamp for stream:  
[DEBUG]      Acquisition_Board-100.Rhythm Data-A 
[DEBUG] Available streams:  
[DEBUG]      Acquisition_Board-100.Rhythm Data 
[DEBUG]      Software 
Error using containers.Map/subsref
The specified key is not present in this container.

Error in BinaryRecording/loadContinuous (line 88)
                stream.metadata.startTimestamp = syncMessages(stream.metadata.id);

Error in BinaryRecording (line 40)
            self = self.loadContinuous();

Error in BinaryRecording.detectRecordings (line 237)
                    recordings{end+1} = BinaryRecording(recordingDirectories{recIdx}, expIdx, recIdx);

Error in RecordNode/detectRecordings (line 95)
                self.recordings = BinaryRecording.detectRecordings(self.directory);

Error in RecordNode (line 71)
            self.detectRecordings();

Error in Session/detectRecordNodes (line 70)
                self.recordNodes{end+1} = RecordNode(paths{i});

Error in Session (line 61)
            self.detectRecordNodes();

which gui version do you use?

medengineer commented 1 year ago

Fixed in v1.3.0