Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to denaturalize a sequence having private tags. #388

Open
vpapaioannou opened this issue Apr 29, 2024 · 1 comment
Open

Fail to denaturalize a sequence having private tags. #388

vpapaioannou opened this issue Apr 29, 2024 · 1 comment

Comments

@vpapaioannou
Copy link

vpapaioannou commented Apr 29, 2024

Assume a sequence SQ with some private tags. dcmjs converts SQ to an array of dictionaries and also converts the tag of headers without a keyword to a number e.g. (2005, 1404) -> 20051404. Hence, the SQ dictionary will have some keys that are string arithmetic e.g. '20051404'. Then, during addAccessor() a property '20051404' will be created. Given though that in Javascript and an array x, x[10] is the same as x['10'], adding a property '20051404' will cause the extension of the SQ to have at least 20051404 elements with undefined values as needed.

This extension causes problems during denaturalization for the SQ; when traversing SQ the undefined sub data sets will be encountered and there will be an error when trying to read these data sets and process their tags.

The remedy would be either to skip the arithmetic tags, to convert the tags back to tuples when adding getter/setter functions or to not covert the tags to numbers at all. Below is an example for skipping.

var addAccessors = function addAccessors(dest, src) {
	Object.keys(src).forEach(function (key) {
	if (!(!isNaN(key) && !isNaN(parseFloat(key)))) {
		// allow non-numeric keys only
		Object.defineProperty(dest, key, {
			get: function get() {
				return src[key];
			},
			set: function set(v) {
				src[key] = v;
			},
			configurable: true
		});
	}
	});
};

This error is found for dcmjs 0.19.9

@pieper
Copy link
Collaborator

pieper commented Apr 30, 2024

Thanks for reporting 👍

I haven't run across data like this in dcmjs. Could you share or create a sample data and make a (failing) test that illustrates the issue so that solutions could be tested?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants