Skip to content

Commit

Permalink
Removed filtering from parser since this provided little benefit
Browse files Browse the repository at this point in the history
  • Loading branch information
karl-exini committed Jun 19, 2019
1 parent f9f77ce commit 474d0c5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 27 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@exini/dicom-streams-js",
"version": "0.0.33",
"version": "0.0.34",
"description": "Streaming parsing and processing of DICOM data",
"main": "node/index.js",
"browser": "web/index.js",
Expand Down
9 changes: 3 additions & 6 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,8 @@ class InFragments extends DicomParseStep {
}

class Parser {
constructor(stop, filter) {
constructor(stop) {
this.stop = stop;
this.filter = filter;

this._builder = new ElementsBuilder();
this._byteParser = new ByteParser(this);
Expand All @@ -252,12 +251,10 @@ class Parser {
}

/**
* Called by byte parser when it is emitting the next parsed element. Check if element should be added
* according to the input filter and add the element to the builder if ok.
* Called by byte parser when it is emitting the next parsed element.
*/
next(element) {
if (!this.filter || this.filter(element, this._builder.currentDepth()))
this._builder.addElement(element);
this._builder.addElement(element);
}

/**
Expand Down
20 changes: 0 additions & 20 deletions test/parser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,26 +337,6 @@ describe("DICOM parse flow", function () {
.expectDicomComplete();
});

it("should filter elements based on the supplied filter condition", function () {
let bytes = base.concatv(data.sequence(Tag.DerivationCodeSequence), base.item(), data.patientNameJohnDoe(), data.studyDate(), base.itemDelimitation(), base.sequenceDelimitation(), data.patientNameJohnDoe());

const stop = (element, depth) => false;
const filter = (element, depth) => depth > 0 || element.tag < Tag.PatientName;
const parser = new Parser(stop, filter);
parser.parse(bytes);

util.partProbe(parser.result().toParts(false))
.expectSequence(Tag.DerivationCodeSequence)
.expectItem(1)
.expectHeader(Tag.PatientName)
.expectValueChunk()
.expectHeader(Tag.StudyDate)
.expectValueChunk()
.expectItemDelimitation()
.expectSequenceDelimitation()
.expectDicomComplete();
});

it("should stop parsing early based on the input stop condition", function () {
let bytes = base.concatv(data.studyDate(), data.sequence(Tag.DerivationCodeSequence), base.item(), data.patientNameJohnDoe(), base.itemDelimitation(), base.sequenceDelimitation(), data.patientNameJohnDoe());

Expand Down

0 comments on commit 474d0c5

Please sign in to comment.