Skip to content

Commit

Permalink
fix: load raw Bruker data
Browse files Browse the repository at this point in the history
  • Loading branch information
jobo322 committed Jun 28, 2024
1 parent 98a376e commit c0779b8
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/converter/util/toJSON/getBrukerFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@ export async function getBrukerFiles(tag, options) {

let relativePath = locationLine.value.spectrum_location;
if (relativePath.match(/file:/s)) {
let pathSpectrum = root + relativePath.replace(/file:/s, '');
let toCheck = pathSpectrum.replace(/(.*\w+\/[0-9]+\/)pdata\/.*/, '$1');
let pathSpectrum = root + relativePath.replace(/file:[./]*/s, '');
const regexRootPath = pathSpectrum.match(/[ser|fid]/s)
? /([.*/]*\w+\/[0-9]+\/).*/
: /(.*\w+\/[0-9]+\/)pdata\/.*/;
let toCheck = pathSpectrum.replace(regexRootPath, '$1');

let toCheck2 = pathSpectrum.replace(
/.*\/[0-9]+\/pdata\/([0-9]+)\/.*/,
'$1',
);
let brukerFolder = [];
for (let file of fileCollection) {
if (
toCheck !== file.relativePath.replace(/([.*/]*\w+\/[0-9]+\/).*/, '$1')
) {
continue;
}
if (file.relativePath.match('pdata')) {
if (
toCheck2 !==
Expand All @@ -35,8 +34,18 @@ export async function getBrukerFiles(tag, options) {
continue;
}
}

const path = file.relativePath.replace(/([.*/]*\w+\/[0-9]+\/).*/, '$1');
if (
toCheck !== path &&
!['ser', 'fid'].some((e) => pathSpectrum === `${path}${e}`)
) {
continue;
}

brukerFolder.push(file);
}

sources.push({
type: 'brukerFiles',
fileCollection: new FileCollection(brukerFolder),
Expand Down

0 comments on commit c0779b8

Please sign in to comment.