Batch converting Neurolucida DAT file format to XML file format

 The issue: I have been writing some scripts in Matlab that permit the direct import of the contour and marker data from the delineations users draw with Neurolucida 360 software. For that purpose, I have been using the option of saving the Neurolucida delineation files in the XML format. Neurolucida 360 permits the user to save their data in several different formats, among them the native binary format (DAT), a standard XML format and an ASC (ASCII type) format. I use XML format because of good documentation (links here and here) provided by MBF. However, Neurolucida 360 saves by default the tracing data in their native binary (DAT) format, so most users will (un)consciously primarily save their data in that format. MBF does not give the key for deciphering this format directly, but attempts were made to reverse engineer the key (link here and here). There is also code available for converting between different tracing formats (NLMorphologyConverter). Unfortunately, this software has not been updated since 2016, and MBF file format has changed since then, so when I tried to use this software, I could only get the marker positions converted, but not the contours. 

Diagnose procedure: After a lot of searching in the MBF website, I found something interesting in their list of NL 360 updates. In 2019, there was included a data2xml batch converter in their program. If you scroll down to the section regarding the version 2019.1.2 updates, you will read about such a converter. 

Solution: You can use this batch converter by following these steps.

1. Open NL 360. You will notice that on the upper right corner of the main interface menu there is an empty text box (marked by a red arrow in the figure under).This is what the MBF website calls a "quick launch box".


2. Type "Convert" on the mentioned field. The autofill function of the box will suggest the option "Convert Files". Choose that option.


3. A new menu will appear with the title "DAT to XML converter". 


4. Choose your Source (folder containing the original DAT files) and Destination (folder that will receive the XML files) folders in the menu. Press the Convert button on the lower left corner to start the process. 


5. After some seconds, the process will be concluded.


Notes: Unfortunately, This conversion is not always effective. I noticed a surprising problem regarding NL360 dat files. If you look closely at a list of DAT files in the figure of the windows file explorer shown under, you will notice that some DAT files are small (some tens of KB size), while others are very big (above 1 MB). 


After some testing, I realized that the small dat files will get correctly converted into xml files, while the big ones will not. The resulting xml files will have a normal heading and the beginning of the main body of data will be normal, but at some point it shows the data in a string of hexadecimal equivalents (that take a lot of space in the text file). The interesting (strange) part is that these files can still be opened normally using NL 360. I tried to find if there is any pattern in the content of such files, but could not find any visible difference between these and the small ones. I guess it is some sort of bug in the saving process. I contacted MBF to understand better the reason behind these bug (!), and will write a post when I solve this mystery. Fortunately, after browsing among the files produced by different NL360 users, I realize that the proportion of "bugged" to "healthy" DAT files is relatively low, so this problem may only occur rarely.  









 

Kommentarer

Populære innlegg fra denne bloggen

Opening Zeiss czi file format mosaic files in Matlab using bio-formats

Possible solution for problems opening confocal files from Zeiss LSM 880 in Neurolucida 360 environment

Opening multileveled TIFF images in Matlab