will2hew / ECGXMLReader

Python class for reading ECG XML files.
14 stars 6 forks source link

list indices must be integers or slices, not str #1

Open rybad80 opened 3 years ago

rybad80 commented 3 years ago

Really awesome work here....I'm trying to get this to work on a GE MUSE ECG XML file but getting this error returned when passing ecg = ECGXMLReader(data, augmentLeads=True) where data is my file path+name

will2hew commented 3 years ago

Are you able to share the ECG file?

rybad80 commented 3 years ago

So unfortunately it has patient information, but I did notice that the following works, so I wonder if addressing the specific index (or looking through somehow) is required?

rawRhythmWaveformLeadI = ECG['RestingECG']['Waveform'][1]['LeadData'][0]['WaveFormData']

rawRhythmWaveformLeadII   = ECG['RestingECG']['Waveform'][1]['LeadData'][1]['WaveFormData']

rawRhythmWaveformLeadV1   = ECG['RestingECG']['Waveform'][1]['LeadData'][2]['WaveFormData']

rawRhythmWaveformLeadV2   = ECG['RestingECG']['Waveform'][1]['LeadData'][3]['WaveFormData']

rawRhythmWaveformLeadV3   = ECG['RestingECG']['Waveform'][1]['LeadData'][4]['WaveFormData']

rawRhythmWaveformLeadV4   = ECG['RestingECG']['Waveform'][1]['LeadData'][5]['WaveFormData']

rawRhythmWaveformLeadV5   = ECG['RestingECG']['Waveform'][1]['LeadData'][6]['WaveFormData']

rawRhythmWaveformLeadV6   = ECG['RestingECG']['Waveform'][1]['LeadData'][7]['WaveFormData']

rawRhythmWaveformLeadV3R  = ECG['RestingECG']['Waveform'][1]['LeadData'][8]['WaveFormData']

rawRhythmWaveformLeadV4R  = ECG['RestingECG']['Waveform'][1]['LeadData'][9]['WaveFormData']

rawRhythmWaveformLeadV7   = ECG['RestingECG']['Waveform'][1]['LeadData'][10]['WaveFormData']
turkalpmd commented 2 days ago

In reference to the discussion regarding errors encountered when utilizing ECGXMLReader for GE MUSE ECG XML files, I believe the pull request I submitted addresses this specific issue.

The problem appears to stem from the structure of the XML file and the way certain indices are accessed within the nested elements, as highlighted in the workaround shared in the thread. My pull request introduces improvements to handle such structural nuances dynamically, eliminating the need for manually specifying indices or workarounds.

By implementing more robust indexing logic and incorporating error handling mechanisms, the updated code ensures compatibility with various XML file structures while preserving data integrity. This should effectively resolve the errors reported and streamline the processing of ECG data from GE MUSE files.

Please feel free to review the changes in detail, and I am open to any feedback or further refinements required to ensure broader applicability.

Here is my PR :