Menu

Two problems opening MUSE XML files

Peter Hull
2013-05-14
2013-06-05
  • Peter Hull

    Peter Hull - 2013-05-14

    Hi. I downloaded the ECG toolkit to look at and process XML files from a GE MAC5500 (in the UK). I found two problems which caused exceptions to be thrown and so prevented it from working.

    1. The date format uses '-' instead of '/' as a separator in AcquisitionDate
    2. Gender can be left blank.

    I wrote a quick patch for both of these, just to get me up and running, but there will probably be other date conversions that also need to be fixed. I'm not a C# person so there may well be a better way to do this.

    Unfortunately I was not able to add either a bug or a support request (the button was not shown on the SF.net UI) so I can only just paste the patch below, hopefully you will be able to read it.

    Thanks for your great work on this project,
    Peter

    Index: libs/ECGConversion/MUSEXML/MUSEXML/MUSEXMLFormat.cs
    ===================================================================
    RCS file: /cvsroot/ecgtoolkit-cs/ECGToolkit/libs/ECGConversion/MUSEXML/MUSEXML/MUSEXMLFormat.cs,v
    retrieving revision 1.1
    diff -r1.1 MUSEXMLFormat.cs
    37a38
    >       private const String _DateFormatAlt = "MM-dd-yyyy";
    760,761c761,764
    <           {   
    <               return DateTime.ParseExact(_Root.TestDemographics.AcquisitionTime + " " + _Root.TestDemographics.AcquisitionDate, _TimeFormat + " " + _DateFormat, CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.None);
    ---
    >           {
    >                   TimeSpan time = TimeSpan.Parse(_Root.TestDemographics.AcquisitionTime);
    >               DateTime date = DateTime.ParseExact(_Root.TestDemographics.AcquisitionDate, new [] {_DateFormat, _DateFormatAlt}, CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.None);
    >               return date + time;
    849c852,866
    <               return (ECGConversion.ECGDemographics.Sex) Enum.Parse(typeof(ECGConversion.ECGDemographics.Sex), _Root.PatientDemographics.Gender, true);
    ---
    >             if (_Root.PatientDemographics.Gender != null)
    >               {
    >                 try
    >               {           
    >                 return (ECGConversion.ECGDemographics.Sex)Enum.Parse(typeof(ECGConversion.ECGDemographics.Sex), _Root.PatientDemographics.Gender, true);
    >               }
    >                 catch (ArgumentException)
    >               {
    >                 return ECGConversion.ECGDemographics.Sex.Null;
    >               }
    >               }
    >             else
    >               {
    >                 return ECGConversion.ECGDemographics.Sex.Unspecified;
    >               }
    
     
  • MJB van Ettinger

    Hi Peter,

    Thanks a lot, always nice to get some feedback. This is a good sign of people actually using the software.

    Probably will release a patch for this next week. Will have to look if this works for any Localization, because it was already used to import an archive into a MUSE in a dutch hospital (I might end up providing a configuration item).

    With Best Regards,

    Maarten

     
  • Peter Hull

    Peter Hull - 2013-05-14

    Thanks for the swift response, glad to see the project's still under active development. Dates and times are always a tricky issue. Here we have the localization of the PC and also the ECG itself. For our GE instrument I couldn't see any settings or any specification from GE as to what is supposed to be in the XML. What system did you use in Holland?

     
  • Peter Hull

    Peter Hull - 2013-05-14

    Follow-up question! Is there a specification for the XML format (I2 format?) available from GE?

     
  • MJB van Ettinger

    Well I'm not sure which GE-MUSE system they were using, but my guess it was a very recent version of there ECG management systems.

    Personally I never saw any specs for the MUSE-XML (a xml stylesheet was all I had), but when I supplied them my first file I had some luck that a GE (or Marquete) technician (or developer) was willing to assist me. There are some very specific requirements for a MUSE-XML to be able to import. Most of them are retracable to the configuration items provided in the MUSE-XML plug-in (run on the commandline: ECGTool.exe -h MUSE-XML):

    Excluded Leads (default value: "III, aVF, aVL, aVR")
    Default AVM (default value: "4.88")
    Default SPS (default value: "500")
    Default Length (default value: "10")
    Default Site (default value: "1")

    Specifically the AVM value worried me a bit. Do also note this plug-in can be used for Resting ECG only.

     
  • MJB van Ettinger

    Your absolutly right, about the change required for the Gender field. So I already changed that part.

    Not yet sure how to solve the DateFormat. But I do think I know why it wasn't an issue earlier. Probably the '-' sign is a european date style (seperator), but in the Netherlands it is very common to have your system in American-English (localization), that would explain why the '/' are used in the hospital I was refering to earlier.

     
  • MJB van Ettinger

    Hi Peter,

    Patch is now provided on the Files section.

    I provided a solution that is configurable for the input and output. Also it will use localization configuration of your system to parse the date and/or time fields.

    I think this will resolve the issue in 99% of the cases (without configuration).

    Let me know if this patch doesn't resolve the issues for you.

    With Best Regards,

    Maarten

     
  • Peter Hull

    Peter Hull - 2013-06-04

    I think configuration would be required in my case. In MUSEXMLFormat.ParseDateTime a typical input 'str' is "10:57:43 05-07-2013" and the generated format list is
    - formats {string[4]} string[]
    [0] "HH:mm:ss MM/dd/yyyy" string
    [1] "HH:mm:ss MM/dd/yyyy" string
    [2] "HH:mm:ss dd/MM/yyyy" string
    [3] "h:mm:ss tt M/d/yyyy" string
    ...so none of these are applicable.
    I'm not sure how to use the config system to select my own date format, could you advise?
    Pete

     
  • MJB van Ettinger

    We are talking about reading these files, right?

    Then you got two options with the provided patch. You can use Localization or provide a Config object during reading.

    Localization is configurable in Windows, in Control Panel. It is all about the ShortDatePattern in your case.

    Other wise you can set these fields of the Config object:
    cfg["Time Format"] = "HH:mm:ss";
    cfg["Date Format"] = "dd-MM-yyyy";
    Assuming you fetched a Config object for MUSE and assigned to: cfg.

    Let me know if this works for you, otherwise I will release another patch.

    PS: for writing XML only the Config object can be used.

     
  • Peter Hull

    Peter Hull - 2013-06-05

    Yes, I am just reading the files. I will modify Config object to suit. I wasn't sure if there was a UI option or something I could put in the .exe.config file
    (as you may realise, I'm not a .NET expert either!!)

     
  • MJB van Ettinger

    Hmm if you're just converting these files using the C# ECG Toolkit, then you can also use the ECGTool.exe and provide:
    -C "Time Format=HH:mm:ss", and
    -C "Date Format=dd-MM-yyyy"
    on the commandline a complete syntax would be (for converting to SCP-ECG):

    ECGTool.exe -C "Time Format=HH:mm:ss" -C "Date Format=dd-MM-yyyy" src.xml SCP-ECG dst.scp

    Sadly for the ECGViewer this capability isn't implemented yet.

     

Log in to post a comment.