Skip to content

Commit d9e4375

Browse files
committed
CLN: Remove generate_uid function as that is being added to pydicom
Minor whitespace cleanup
1 parent a195fa1 commit d9e4375

File tree

2 files changed

+8
-45
lines changed

2 files changed

+8
-45
lines changed

nibabel/nicom/utils.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -87,43 +87,6 @@ def find_private_element(dcm_data, group_no, creator, elem_offset):
8787
return dcm_data.get((group_no, sect_start + elem_offset))
8888

8989

90-
def make_uid(entropy_srcs=None, prefix='2.25.'):
91-
'''Generate a DICOM UID value.
92-
93-
Follows the advice given at:
94-
http://www.dclunie.com/medical-image-faq/html/part2.html#UID
95-
96-
Parameters
97-
----------
98-
entropy_srcs : list of str or None
99-
List of strings providing the entropy used to generate the UID. If
100-
None these will be collected from a combination of HW address, time,
101-
process ID, and randomness.
102-
prefix : str
103-
The prefix used for the UID.
104-
105-
Returns
106-
-------
107-
uid : str
108-
The the DICOM uid that was generated.
109-
'''
110-
if len(prefix) >= 64:
111-
raise ValueError("The prefix must be less than 64 chars long")
112-
# Combine all the entropy sources with a hashing algorithm
113-
if entropy_srcs is None:
114-
entropy_srcs = [str(uuid.uuid1()), # 128-bit from MAC/time/randomness
115-
str(os.getpid()), # Current process ID
116-
random().hex() # 64-bit randomness
117-
]
118-
hash_val = hashlib.sha256(asbytes(''.join(entropy_srcs)))
119-
120-
# Converet this to an int with the maximum available digits
121-
avail_digits = 64 - len(prefix)
122-
int_val = int(hash_val.hexdigest(), 16) % (10 ** avail_digits)
123-
fmt_str = '%%0%dd' % avail_digits
124-
return prefix + (fmt_str % int_val)
125-
126-
12790
def as_to_years(age_str):
12891
'''Convert a DICOM age value (value representation of 'AS') to the age in
12992
years.

nibabel/tests/test_xpparse.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -665,23 +665,23 @@ def test_pipe_service():
665665
<ParamLong."DATATHREADS"> { }
666666
<ParamLong."WATERMARK"> { 16 }
667667
<ParamString."tdefaultEVAProt"> { "%SiemensEvaDefProt%/DTI/DTI.evp" }
668-
<ParamFunctor."MosaicUnwrapper">
668+
<ParamFunctor."MosaicUnwrapper">
669669
{
670-
<Class> "MosaicUnwrapper@IceImagePostProcFunctors"
670+
<Class> "MosaicUnwrapper@IceImagePostProcFunctors"
671671
672672
<ParamBool."EXECUTE"> { }
673673
<Event."ImageReady"> { "int32_t" "class IceAs &" "class MrPtr<class MiniHeader,class Parc::Component> &" "class ImageControl &" }
674674
<Method."ComputeImage"> { "int32_t" "class IceAs &" "class MrPtr<class MiniHeader,class Parc::Component> &" "class ImageControl &" }
675675
<Connection."c1"> { "ImageReady" "" "ComputeImage" }
676676
}
677-
<ParamFunctor."DtiIcePostProcFunctor">
677+
<ParamFunctor."DtiIcePostProcFunctor">
678678
{
679-
<Class> "DtiIcePostProcFunctor@DtiIcePostProc"
679+
<Class> "DtiIcePostProcFunctor@DtiIcePostProc"
680680
681681
<ParamBool."EXECUTE"> { "true" }
682-
<ParamArray."BValue">
682+
<ParamArray."BValue">
683683
{
684-
<Default> <ParamLong."">
684+
<Default> <ParamLong."">
685685
{
686686
}
687687
{ }
@@ -722,9 +722,9 @@ def test_pipe_service():
722722
<Event."ImageReady"> { "int32_t" "class IceAs &" "class MrPtr<class MiniHeader,class Parc::Component> &" "class ImageControl &" }
723723
<Connection."c1"> { "ImageReady" "DtiIcePostProcMosaicDecorator" "ComputeImage" }
724724
}
725-
<ParamFunctor."DtiIcePostProcMosaicDecorator">
725+
<ParamFunctor."DtiIcePostProcMosaicDecorator">
726726
{
727-
<Class> "DtiIcePostProcMosaicDecorator@DtiIcePostProc"
727+
<Class> "DtiIcePostProcMosaicDecorator@DtiIcePostProc"
728728
729729
<ParamBool."EXECUTE"> { "true" }
730730
<ParamBool."Mosaic"> { "true" }

0 commit comments

Comments
 (0)