dicom 0.7 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dicom
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.7"
4
+ version: "0.8"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoffer Lervag
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-28 00:00:00 +01:00
12
+ date: 2010-08-01 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: DICOM is a standard widely used throughout the world to store and transfer medical image data. This project aims to make a library that is able to handle DICOM in the Ruby language, to the benefit of any student or professional who would like to use Ruby to process their DICOM files or communicate across the network.
16
+ description: DICOM is a standard widely used throughout the world to store and transfer medical image data. This library enables efficient and powerful handling of DICOM in Ruby, to the benefit of any student or professional who would like to use their favorite language to process DICOM files and communicate across the network.
17
17
  email: chris.lervag@gmail.com
18
18
  executables: []
19
19
 
@@ -23,22 +23,29 @@ extra_rdoc_files: []
23
23
 
24
24
  files:
25
25
  - lib/dicom.rb
26
- - lib/dicom/DObject.rb
27
- - lib/dicom/Link.rb
28
- - lib/dicom/DLibrary.rb
29
- - lib/dicom/DWrite.rb
30
- - lib/dicom/Dictionary.rb
31
- - lib/dicom/FileHandler.rb
32
- - lib/dicom/DServer.rb
33
- - lib/dicom/DClient.rb
34
- - lib/dicom/Anonymizer.rb
35
- - lib/dicom/Stream.rb
26
+ - lib/dicom/dictionary.rb
27
+ - lib/dicom/constants.rb
28
+ - lib/dicom/item.rb
29
+ - lib/dicom/anonymizer.rb
30
+ - lib/dicom/d_object.rb
31
+ - lib/dicom/stream.rb
32
+ - lib/dicom/sequence.rb
33
+ - lib/dicom/super_item.rb
34
+ - lib/dicom/link.rb
35
+ - lib/dicom/file_handler.rb
36
+ - lib/dicom/d_write.rb
37
+ - lib/dicom/d_server.rb
38
+ - lib/dicom/super_parent.rb
36
39
  - lib/dicom/ruby_extensions.rb
37
- - lib/dicom/DRead.rb
40
+ - lib/dicom/d_read.rb
41
+ - lib/dicom/d_client.rb
42
+ - lib/dicom/elements.rb
43
+ - lib/dicom/d_library.rb
44
+ - lib/dicom/data_element.rb
45
+ - CHANGELOG
38
46
  - README
39
- - DOCUMENTATION
40
47
  - COPYING
41
- - CHANGELOG
48
+ - init.rb
42
49
  has_rdoc: true
43
50
  homepage: http://dicom.rubyforge.org/
44
51
  licenses: []
@@ -52,13 +59,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
59
  requirements:
53
60
  - - ">="
54
61
  - !ruby/object:Gem::Version
55
- version: "0"
62
+ version: 1.8.6
56
63
  version:
57
64
  required_rubygems_version: !ruby/object:Gem::Requirement
58
65
  requirements:
59
66
  - - ">="
60
67
  - !ruby/object:Gem::Version
61
- version: "0"
68
+ version: 1.3.4
62
69
  version:
63
70
  requirements: []
64
71
 
data/DOCUMENTATION DELETED
@@ -1,469 +0,0 @@
1
- Ruby DICOM is a small and simple library for handling DICOM files (reading, editing
2
- and writing) and DICOM network communication (both client and server side).
3
- It is written completely in Ruby and has no external dependencies.
4
-
5
- Copyright 2008-2010 Christoffer Lervåg (chris.lervag [@nospam] @gmail.com)
6
-
7
- INSTALLATION
8
-
9
- gem install dicom
10
-
11
- *************************************************************************
12
-
13
- DOCUMENTATION
14
-
15
- CLASS DObject
16
-
17
- PUBLIC CLASS METHODS
18
-
19
- new(filename, options={})
20
-
21
- Initialize a new DICOM object.
22
- Example 1: (The simplest way)
23
- require 'dicom'
24
- obj = DICOM::DObject.new("myFile.dcm")
25
- Example 2: (Reading a DICOM file that has already been loaded into memory in a binary string)
26
- obj = DICOM::DObject.new(bin_data, :bin => true, :syntax => syntax_string)
27
- Example 3: (Open an empty DICOM object & choose non-verbose behaviour)
28
- obj = DICOM::DObject.new(nil, :verbose => false)
29
-
30
- ACCESSORS (read only)
31
- :read_success
32
- A boolean that is true if DICOM object was read successfully, and false if not.
33
- :write_success
34
- A boolean that is true if DICOM object was written successfully, and false if not.
35
- :errors
36
- An array holding any error messages, warnings or notices that have been logged
37
- during your interaction with DObject.
38
- :modality
39
- A string which holds the description of the modality of the DICOM object that has been read.
40
- Example of use:
41
- obj = DICOM::DObject.new("myFile.dcm")
42
- if obj.read_success
43
- puts obj.modality
44
- end
45
- The following accessors are the arrays that hold all the information gathered on the DICOM object.
46
- As such, their length is equal to the number of tags in a DICOM object.
47
- :names
48
- :tags
49
- :vr
50
- :lengths
51
- :values
52
- :bin
53
- :levels
54
-
55
- PUBLIC INSTANCE METHODS
56
-
57
- children(element, options={})
58
- Returns the positions of all data elements inside the hierarchy of a sequence or an item.
59
- This is useful if you later want to get the position(s) of a certain element,
60
- restricted to the positions inside the given sequence or item.
61
- Element may be an array index, element name or element tag.
62
- Example 1: (Return all element positions that is contained in the following sequence)
63
- pos = obj.children("3006,0082")
64
- Example 2: (Return all element positions that is contained only directly beneath the following sequence)
65
- pos = obj.children("3006,0082", :next_only => true)
66
-
67
- get_bin(element, options={})
68
- Returns the unprocessed, binary string of the requested DICOM data element.
69
- Element may be an array index, element name or element tag.
70
- If you wish to return multiple data values of a tag that occurs several times in the file,
71
- use the keyword :array => true .
72
- Example: (Returns all data values in a array)
73
- contour_data = obj.get_bin("3006,0050", :array => true)
74
-
75
- get_frames
76
- Returns the number of frames present in the image data in the DICOM file.
77
-
78
- get_image(options={})
79
- Returns a standard Ruby array with the pixel data, where the length of the array corresponds
80
- with the number of pixels in the image.
81
- Example 1: (Retrieve the pixel data)
82
- pixels = obj.get_image
83
- Example 2: (Retrieve the pixel data rescaled to presentation values according to window center/width settings)
84
- pixels = obj.get_image(:rescale => true)
85
- Example 3: (Retrieve the rescaled pixel data and using a numerical array in the rescaling process (~2 times faster))
86
- pixels = obj.get_image(:rescale => true, :narray => true)
87
-
88
- get_image_magick(options={})
89
- Returns an array of RMagick image objects, where the size of the array corresponds
90
- with the number of frames in the image data.
91
- To call this method the user needs to have loaded the RMagick bindings in advance (require 'RMagick').
92
- Example 1: (Retrieve object and display first frame)
93
- require 'RMagick'
94
- images = obj.get_image_magick
95
- images[0].display
96
- Example 2: (Retrieve image object rescaled to presentation values according to window center/width settings)
97
- images = obj.get_image_magick(:rescale => true)
98
- Example 3: (Retrieve rescaled image object and using a numerical array in the rescaling process (~2 times faster))
99
- images = obj.get_image_magick(:rescale => true, :narray => true)
100
-
101
- get_image_narray(options={})
102
- Returns a 3d NArray object where the array dimensions are related to [frames, columns, rows].
103
- To call this method the user needs to have loaded the NArray library in advance (require 'narray').
104
- Example 1: (Retrieve object and display first frame):
105
- require 'narray'
106
- require 'nimage'
107
- data = obj.get_image_narray
108
- NImage.show data[0,true,true]
109
- Example 2: (Retrieve numerical array rescaled from the original pixel values to presentation values)
110
- data = obj.get_image_narray(:rescale => true)
111
-
112
- get_image_pos
113
- Returns the index(es) of the data element(s) that contain image data.
114
-
115
- get_pos(string, options={})
116
- Returns the index(es) of the data element(s) in the DICOM file that match
117
- the supplied element tag or name.
118
- Example 1: (Find all occurences of the specified tag in the object)
119
- pos = obj.get_pos("3006,0080")
120
- Example 2: (Find all occurences of the specified tag inside the specified sequence)
121
- mySelection = obj.children("3006,0082")
122
- pos = obj.get_pos("3006,0080", :selection => mySelection)
123
- Example 3: (Same as above, but slightly more concise using the :parent option)
124
- pos = obj.get_pos("3006,0080", :parent => "3006,0082")
125
- Example 4: (Using the :partial argument to find position of all elements containing a specific string)
126
- pos = obj.get_pos("0010", :partial => true)
127
- pos = obj.get_pos("Name", :partial => true)
128
-
129
- get_value(element)
130
- Returns the value (processed binary data) of the requested DICOM data element.
131
- Element may be an array index, element name or element tag.
132
- If you wish to return multiple values of a tag that occurs several times in the file,
133
- use the keyword :array => true .
134
- Example: (Returns all data values in a array)
135
- contour_data = obj.get_value("3006,0050", :array => true)
136
-
137
- image_to_file(file)
138
- Dumps the pixel data of the DICOM object directly to the specified file.
139
- This is useful if you wish to extract this data to process it with another program.
140
-
141
- parents(element)
142
- Returns the positions of all parents of this tag in the hierarchy.
143
- This is useful if you want to know the position of the items or sequence tags that 'hold' your tag.
144
- Element may be an array index, element name or element tag.
145
- Example:
146
- pos = obj.parents("300C,0006")
147
-
148
- print(pos, options={})
149
- Prints the information gathered on one or several/all tag(s) in the DICOM object:
150
- (index, [hierarchy level,] label, name, vr, length, value)
151
- The method can print to both screen or to a text file. If print to file is chosen,
152
- the text file will be put in the folder of the original DICOM file with a '.txt' extension.
153
- The argument pos may be a number (array position), an array of numbers, or true.
154
- Example 1: (Print all tags to file, with both tree visualization and level numbers)
155
- obj.print(true, :levels => true, :tree => true, :file => true)
156
- Example 2: (Print an array of tags to screen, no level or tree visualization)
157
- obj.print([4,5,6])
158
-
159
- print_all
160
- Prints information of all tags stored in the DICOM object to the screen (This is equal to using print(true)).
161
-
162
- print_properties
163
- Prints the key structural properties of the DICOM file to the screen.
164
-
165
- remove(element, options={})
166
- Removes the specified data element from the DICOM object. You can use this method
167
- if you are editing a DICOM object and wants to get rid of one or more elements.
168
- Element may be an array index, element name or element tag.
169
- The default behaviour of this method is to remove any encapsulated elements if a sequence
170
- or item is selected for removal. If for some reason you want to avoid this, user the :ignore_children option.
171
- Example 1: (Remove a sequence tag along with all its 'children' tags)
172
- obj.remove("Request Attributes Sequence")
173
- Example 2: (Remove a specific sequence tag only (not recommended unless you really know what you are doing))
174
- obj.remove("0040,0275", :ignore_children => true)
175
-
176
- remove_private
177
- Removes all private data elements from the DICOM object.
178
-
179
- set_image(array)
180
- Encodes and inserts the content of your array to the pixel data element of your DICOM object.
181
- Note that this method does not create or update tags related to image information in the DICOM object.
182
-
183
- set_image_file(file)
184
- Inserts the binary content of a file to the Pixel Data tag in your DICOM object.
185
- This can be useful if you have processed some image data using a custom program
186
- and just wants to put that data back into a DICOM object.
187
-
188
- set_image_magick(object, options={})
189
- Encodes and inserts a RMagick image object to the pixel data element of your DICOM object.
190
- Note that this method does not create or update tags related to image information in the DICOM object.
191
- If pixel value rescaling is desired, this can be specified by using both the :min and :max options.
192
- NB! Because of rescaling when importing pixel values to a RMagick object, and the possible
193
- difference between presentation values and original pixel values, the use of set_image_magick() may
194
- result in pixel data that is completely different from what is expected.
195
- This method should be used only with great care: Do not be suprised if your resulting DICOM image looks strange!
196
- Example: (Encode an image object and requesting a specific pixel value range to be encoded)
197
- obj.set_image_magick(myImage, :min => -2000, :max => 3000)
198
-
199
- set_image_narray(object, options={})
200
- Encodes and inserts a NArray object to the pixel data element of your DICOM object.
201
- Note that this method does not create or update tags related to image information in the DICOM object.
202
- If pixel value rescaling is desired, this can be specified by using both the :min and :max options.
203
- Example: (Encode a numerical pixel data array and requesting a specific pixel value range to be encoded)
204
- obj.set_image_narray(myArray, :min => -2000, :max => 3000)
205
-
206
- set_value(value, element, options={})
207
- This method can be used both to edit an existing data element, or to create
208
- new data elements in your DICOM object.
209
- Element may be an array index, element name or element tag.
210
- Example 1: (Edit patient name)
211
- obj.set_value("Anonymous", "0010,0010", :create => false)
212
- Example 2: (Insert binary data for a specific tag)
213
- obj.set_value(data, 52, :bin => true, :create => false)
214
- Example 3: (Create a private data element)
215
- obj.set_value("Test", "0011,0010", :vr => "LO")
216
- Example 4: (Create/edit a data element in a specific item in a given sequence)
217
- items = obj.get_pos("FFFE,E000", :parent => "0040,0275")
218
- obj.set_value("CT1", "0040,0007", :parent => items.first)
219
-
220
- write(file)
221
- Writes the DICOM object to the specified file.
222
- Example:
223
- obj.write(myPath + "test_file.dcm")
224
-
225
-
226
- CLASS Anonymizer
227
-
228
- PUBLIC CLASS METHODS
229
-
230
- new()
231
- Initialize a new Anonymizer instance.
232
- Example:
233
- a = DICOM::Anonymizer.new
234
-
235
- ACCESSORS (Read & write)
236
- :blank
237
- A boolean that you can set as true if you want all anonymization tags to be blank
238
- instead of having some generic value.
239
- :enumeration
240
- A boolean that if set as true will make the script set enumerated values on anonymized tags,
241
- such that you are able to separate the DICOM files of unique individuals after anonymization.
242
- Example of fictious result:
243
- "Joe Sixpack" => "Person1" and "Joe Schmoe" => "Person2"
244
- :identity_file
245
- If you request enumeration, you can specify an identity file which will enable you to reidentify
246
- the anonymized DICOM files at a later stage. The relationship between original names and
247
- enumerated values is stored in a text file which you can keep for yourself, while handing out
248
- the anonymized DICOM files to a third party.
249
- :remove_private
250
- If this accessor is set as true, all private tags in the selected DICOM files will be removed.
251
- This can be useful if you are unsure whether the private tags contain sensitive data or not.
252
- :write_path
253
- You may set a different path for where the anonymized DICOM files will be stored. If this
254
- value is not set, the Anonymizer script will overwrite the old DICOM files.
255
- Example:
256
- a.write_path = "C:/temp/"
257
-
258
- PUBLIC INSTANCE METHODS
259
-
260
- add_exception(path)
261
- Adds a folder who's files (including all files in its subfolders) will be excluded from anonymization.
262
-
263
- add_folder(path)
264
- Adds a folder who's files (including all files in subfolders) will be anonymized.
265
- Example:
266
- a.add_folder("/home/dicom")
267
-
268
- add_tag(tag, options={})
269
- Adds a tag to the list of tags that will be anonymized. As options you can specify value to be used
270
- and whether the tag should be included for enumeration if this feature has been activated.
271
- Example:
272
- a.add_tag("0010,0010, :value => "MrAnonymous", :enum => true)
273
-
274
- change_enum(tag, status)
275
- Sets enumeration status for a specific tag. Status = true means the selected tag will get
276
- an enumerated value, false means it will not.
277
-
278
- execute(verbose)
279
- Executes the anonymization process. Run this method when you are finished choosing all your settings.
280
- Verbose (=true/false) will apply to the read/update/write process that takes place in DObject, and not
281
- the messages of the Anonymization script itself.
282
-
283
- print
284
- Prints the list of tags that have been selected for anonymization, along with the values
285
- that the original tags will be replaced with. If enumeration is selected, this method will also
286
- print which tags have been selected for enumeration.
287
-
288
- remove_tag(tag)
289
- Removes a tag from the list of tags that will be anonymized.
290
- Example:
291
- a.remove_tag("0010,0010")
292
-
293
-
294
- CLASS DClient
295
-
296
- PUBLIC CLASS METHODS
297
-
298
- new(host_ip, port, options={})
299
- Initialize a new DClient instance.
300
- Example:
301
- node = DICOM::DClient.new("10.1.25.200", 104)
302
-
303
- ACCESSORS (Read & write)
304
- :ae
305
- Calling application entity (name of the service class user - client).
306
- :host_ae
307
- Called application entity (name of the service class provider - server).
308
- :host_ip
309
- The host (server) ip adress.
310
- :max_package_size
311
- Maximum size of transferred network packages.
312
- :port
313
- Port number to be used in the network communication.
314
- :timeout
315
- Timeout (in seconds) to be used in the network communication.
316
- :verbose
317
- Verbosity with regards to notices and error messages (true or false).
318
- ACCESSORS (Read only)
319
- :command_results
320
- An array holding any received command results.
321
- :data_results
322
- An array holding any received data results.
323
- :errors
324
- An array holding any error messages that have occurred in this session.
325
- :notices
326
- An array holding any informational messages presented in this session.
327
-
328
- PUBLIC INSTANCE METHODS
329
-
330
- find_images(options={})
331
- Query a server for DICOM images that matches your specified criteria.
332
- Accepted options:
333
- "0008,0018" (SOP Instance UID)
334
- "0008,0052" (Query/Retrieve Level)
335
- "0020,000D" (Study Instance UID)
336
- "0020,000E" (Series Instance UID)
337
- "0020,0013" (Instance Number)
338
- Example:
339
- result = node.find_images("0010,0020" => patient_id, "0020,000D" => study_uid, "0020,000E" => series_uid)
340
-
341
- find_patients(options={})
342
- Query a server for patients that matches your specified criteria.
343
- Accepted options:
344
- "0008,0052" (Query/Retrieve Level)
345
- "0010,0010" (Patient's Name)
346
- "0010,0020" (Patient ID)
347
- "0010,0030" (Patient's Birth Date)
348
- "0010,0040" (Patient's Sex)
349
- Example:
350
- result = node.find_patients("0010,0010" => "James*")
351
-
352
- find_series(options={})
353
- Query a server for series that matches your specified criteria.
354
- Accepted options:
355
- "0008,0052" (Query/Retrieve Level)
356
- "0008,0060" (Modality)
357
- "0008,103E" (Series Description)
358
- "0020,000D" (Study Instance UID)
359
- "0020,000E" (Series Instance UID)
360
- "0020,0011" (Series Number)
361
- Example:
362
- result = node.find_series("0010,0020" => patient_id, "0020,000D" => study_uid)
363
-
364
- find_studies(options={})
365
- Query a server for studies that matches your specified criteria.
366
- Accepted options:
367
- "0008,0020" (Study Date)
368
- "0008,0030" (Study Time)
369
- "0008,0050" (Accession Number)
370
- "0008,0052" (Query/Retrieve Level)
371
- "0008,0090" (Referring Physician's Name)
372
- "0008,1030" (Study Description)
373
- "0008,1060" (Name of Physician(s) Reading Study)
374
- "0010,0010" (Patient's Name)
375
- "0010,0020" (Patient ID)
376
- "0010,0030" (Patient's Birth Date)
377
- "0010,0040" (Patient's Sex)
378
- "0020,000D" (Study Instance UID)
379
- "0020,0010" (Study ID)
380
- Example:
381
- result = node.find_studies("0008,0020" => study_date, "0010,000D" => patient_id)
382
-
383
- get_image(path, options={})
384
- Retrieve a DICOM image file from a server (C-GET-RQ) (this method is untested (might not work)).
385
- Accepted options:
386
- "0008,0018" (SOP Instance UID)
387
- "0008,0052" (Query/Retrieve Level)
388
- "0020,000D" (Study Instance UID)
389
- "0020,000E" (Series Instance UID)
390
- Example:
391
- node.get_image("/home/dicom/", "0008,0018" => sop_uid, "0020,000D" => study_uid, "0020,000E" => series_uid)
392
-
393
- move_image(destination, options={})
394
- Move an image to a dicom node other than yourself.
395
- Accepted options:
396
- "0008,0018" (SOP Instance UID)
397
- "0008,0052" (Query/Retrieve Level)
398
- "0020,000D" (Study Instance UID)
399
- "0020,000E" (Series Instance UID)
400
- Example:
401
- node.move_image("MYDICOM", "0008,0018" => sop_uid, "0020,000D" => study_uid, "0020,000E" => series_uid)
402
-
403
- move_study(destination, options={})
404
- Move an entire study to a dicom node other than yourself.
405
- Accepted options:
406
- "0008,0052" (Query/Retrieve Level)
407
- "0010,0020" (Patient ID)
408
- "0020,000D" (Study Instance UID)
409
- Example:
410
- node.move_study("MYDICOM", "0010,0020" => patient_id, "0020,000D" => study_uid)
411
-
412
- send(file_path)
413
- Send a DICOM file to a service class provider (SCP/PACS).
414
- Example:
415
- node.send("myFile.dcm")
416
-
417
- test
418
- Tests a connection with your DICOM server by trying a simple association.
419
-
420
-
421
- CLASS DServer
422
-
423
- PUBLIC CLASS METHODS
424
-
425
- new(port, options={})
426
- Initialize a new DServer instance.
427
- Example 1:
428
- server = DICOM::DServer.new(104)
429
- Example 2: (Initialize a DServer using a customized FileHandler placed in your local folder)
430
- require 'MyFileHandler'
431
- server = DICOM::DServer.new(104, :host_ae => "RUBY_SERVER", :file_handler => DICOM::MyFileHandler)
432
-
433
- ACCESSORS (Read & write)
434
- :file_handler
435
- You may write your own, customized FileHandler (the file that determines how incoming DICOM files are handled),
436
- put it in your local execution environment, and hook it to your DServer instance by using this accessor.
437
- This is quite a powerful option, as it will enable you to do practically whatever you want with incoming DICOM files.
438
- :host_ae
439
- Called application entity (name of the service class provider - server).
440
- :max_package_size
441
- Maximum size of transferred network packages.
442
- :port
443
- Port number to be used in the network communication.
444
- :timeout
445
- Timeout (in seconds) to be used in the network communication.
446
- :verbose
447
- Verbosity with regards to notices and error messages (true or false).
448
- ACCESSORS (Read only)
449
- :errors
450
- An array holding any error messages that have occurred in this session.
451
- :notices
452
- An array holding any informational messages presented in this session.
453
-
454
- PUBLIC INSTANCE METHODS
455
-
456
- add_abstract_syntax(value)
457
- Adds a specified abstract syntax to the list of syntaxes that is accepted by the server.
458
-
459
- print_syntaxes
460
- Prints the list of abstract syntaxes that is accepted by the server.
461
-
462
- remove_abstract_syntax(value)
463
- Removes a specified abstract syntax from the list of syntaxes that is accepted by the server.
464
-
465
- remove_all_abstract_syntaxes
466
- Completely clears the list of syntaxes that the server instance will accept.
467
-
468
- start_scp(path)
469
- Launch the simple storage server (Storage Content Provider - SCP).