pacsretrieve/pacsretrieve.py
def jpgPreview_generate(self, *args, **kwargs):
        """
        Generate a jpg preview of the DICOMS in a list of directories
        containing DICOM data.
        """
        lstr_DICOMdirs  = []
        b_status        = False
        d_ret           = {}

        for k,v in kwargs.items():
            if k == 'l_DICOMdirs':    lstr_DICOMdirs    = v

        for str_DICOMdir in lstr_DICOMdirs:
            self.dp.qprint('In directory %s...' % str_DICOMdir)
            # create a jpg subdir
            str_jpgDir  = os.path.join(str_DICOMdir, 'jpg')
            os.makedirs(str_jpgDir)
            self.dp.qprint('Creating jpg dir %s...' % str_jpgDir)

            # Loop over every DICOM to create a JPG
            # pudb.set_trace()
            os.chdir(str_DICOMdir)
            l_lsDCM     = glob.glob('*.dcm')
            self.dp.qprint('Generating raw jpg from %d DICOM files...' % len(l_lsDCM))
            for str_FQfile in l_lsDCM:
                str_file, str_ext = os.path.splitext(str_FQfile)
                if str_ext == '.dcm':
                    str_inputDICOMfile  = os.path.join(str_DICOMdir, str_FQfile)
                    str_outputJPGfile   = os.path.join(str_jpgDir, str_file) 

                    # Convert to jpg
                    str_cmd = '/usr/bin/dcmj2pnm +oj +Wh 15 +Fa ' + str_inputDICOMfile + \
                                ' ' + str_outputJPGfile
                    str_response = subprocess.run(  str_cmd, 
                                                    stdout = subprocess.PIPE,
                                                    stderr = subprocess.STDOUT,
                                                    shell  = True
                                                )

            # Loop over every JPG to resize
            # pudb.set_trace()
            l_lsjpg     = os.listdir(str_jpgDir)
            self.dp.qprint('Resizing %d jpg images...' % len(l_lsjpg))
            for str_FQfile  in l_lsjpg:
                str_cmd = '/usr/bin/mogrify -resize 96x96 -background none -gravity center -extent 96x96 ' + \
                            os.path.join(str_jpgDir, str_FQfile)
                str_response = subprocess.run(  str_cmd, 
                                                stdout = subprocess.PIPE,
                                                stderr = subprocess.STDOUT,
                                                shell  = True
                                            )
            # Now create a preview
            # pudb.set_trace()
            self.dp.qprint('Appending all jpgs into a preview...')
            str_cmd = '/usr/bin/convert -append ' + os.path.join(str_jpgDir,   '*') + ' ' + \
                                                    os.path.join(str_DICOMdir, 'preview.jpg')                                 
            str_response = subprocess.run(  str_cmd, 
                                            stdout = subprocess.PIPE,
                                            stderr = subprocess.STDOUT,
                                            shell  = True
                                        )

        Generate a jpg preview of the DICOMS in a list of directories
        containing DICOM data.
        
Generate a jpg preview of the DICOMS in a list of directories
containing DICOM data.
Generate a jpg preview of the DICOMS in a list of directories containing DICOM data .
def jpgPreview_generate(self, *args, **kwargs):
        lstr_DICOMdirs  = []
        b_status        = False
        d_ret           = {}
        for k,v in kwargs.items():
            if k == 'l_DICOMdirs':    lstr_DICOMdirs    = v
        for str_DICOMdir in lstr_DICOMdirs:
            self.dp.qprint('In directory %s...' % str_DICOMdir)
            str_jpgDir  = os.path.join(str_DICOMdir, 'jpg')
            os.makedirs(str_jpgDir)
            self.dp.qprint('Creating jpg dir %s...' % str_jpgDir)
            os.chdir(str_DICOMdir)
            l_lsDCM     = glob.glob('*.dcm')
            self.dp.qprint('Generating raw jpg from %d DICOM files...' % len(l_lsDCM))
            for str_FQfile in l_lsDCM:
                str_file, str_ext = os.path.splitext(str_FQfile)
                if str_ext == '.dcm':
                    str_inputDICOMfile  = os.path.join(str_DICOMdir, str_FQfile)
                    str_outputJPGfile   = os.path.join(str_jpgDir, str_file) 
                    str_cmd = '/usr/bin/dcmj2pnm +oj +Wh 15 +Fa ' + str_inputDICOMfile + \
                                ' ' + str_outputJPGfile
                    str_response = subprocess.run(  str_cmd, 
                                                    stdout = subprocess.PIPE,
                                                    stderr = subprocess.STDOUT,
                                                    shell  = True
                                                )
            l_lsjpg     = os.listdir(str_jpgDir)
            self.dp.qprint('Resizing %d jpg images...' % len(l_lsjpg))
            for str_FQfile  in l_lsjpg:
                str_cmd = '/usr/bin/mogrify -resize 96x96 -background none -gravity center -extent 96x96 ' + \
                            os.path.join(str_jpgDir, str_FQfile)
                str_response = subprocess.run(  str_cmd, 
                                                stdout = subprocess.PIPE,
                                                stderr = subprocess.STDOUT,
                                                shell  = True
                                            )
            self.dp.qprint('Appending all jpgs into a preview...')
            str_cmd = '/usr/bin/convert -append ' + os.path.join(str_jpgDir,   '*') + ' ' + \
                                                    os.path.join(str_DICOMdir, 'preview.jpg')                                 
            str_response = subprocess.run(  str_cmd, 
                                            stdout = subprocess.PIPE,
                                            stderr = subprocess.STDOUT,
                                            shell  = True
                                        )
def jpgPreview_generate ( self , * args , ** kwargs ) : lstr_DICOMdirs = [ ] b_status = False d_ret = { } for k , v in kwargs . items ( ) : if k == 'l_DICOMdirs' : lstr_DICOMdirs = v for str_DICOMdir in lstr_DICOMdirs : self . dp . qprint ( 'In directory %s...' % str_DICOMdir ) str_jpgDir = os . path . join ( str_DICOMdir , 'jpg' ) os . makedirs ( str_jpgDir ) self . dp . qprint ( 'Creating jpg dir %s...' % str_jpgDir ) os . chdir ( str_DICOMdir ) l_lsDCM = glob . glob ( '*.dcm' ) self . dp . qprint ( 'Generating raw jpg from %d DICOM files...' % len ( l_lsDCM ) ) for str_FQfile in l_lsDCM : str_file , str_ext = os . path . splitext ( str_FQfile ) if str_ext == '.dcm' : str_inputDICOMfile = os . path . join ( str_DICOMdir , str_FQfile ) str_outputJPGfile = os . path . join ( str_jpgDir , str_file ) str_cmd = '/usr/bin/dcmj2pnm +oj +Wh 15 +Fa ' + str_inputDICOMfile + ' ' + str_outputJPGfile str_response = subprocess . run ( str_cmd , stdout = subprocess . PIPE , stderr = subprocess . STDOUT , shell = True ) l_lsjpg = os . listdir ( str_jpgDir ) self . dp . qprint ( 'Resizing %d jpg images...' % len ( l_lsjpg ) ) for str_FQfile in l_lsjpg : str_cmd = '/usr/bin/mogrify -resize 96x96 -background none -gravity center -extent 96x96 ' + os . path . join ( str_jpgDir , str_FQfile ) str_response = subprocess . run ( str_cmd , stdout = subprocess . PIPE , stderr = subprocess . STDOUT , shell = True ) self . dp . qprint ( 'Appending all jpgs into a preview...' ) str_cmd = '/usr/bin/convert -append ' + os . path . join ( str_jpgDir , '*' ) + ' ' + os . path . join ( str_DICOMdir , 'preview.jpg' ) str_response = subprocess . run ( str_cmd , stdout = subprocess . PIPE , stderr = subprocess . STDOUT , shell = True )
Generate a jpg preview of the DICOMS in a list of directories
containing DICOM data.
Generate a jpg preview of the DICOMS in a list of directories containing DICOM data .
"""
        Generate a jpg preview of the DICOMS in a list of directories
        containing DICOM data.
        """ # create a jpg subdir # Loop over every DICOM to create a JPG # pudb.set_trace() # Convert to jpg # Loop over every JPG to resize # pudb.set_trace() # Now create a preview # pudb.set_trace()
self