public static boolean hasSameOrientation(MediaSeries<DicomImageElement> series1, MediaSeries<DicomImageElement> series2) { // Test if the two series have the same orientation if (series1 != null && series2 != null) { DicomImageElement image1 = series1.getMedia(MEDIA_POSITION.MIDDLE, null, null); DicomImageElement image2 = series2.getMedia(MEDIA_POSITION.MIDDLE, null, null); return hasSameOrientation(image1, image2); } return false; }
public static boolean hasSameSize(MediaSeries<DicomImageElement> series1, MediaSeries<DicomImageElement> series2) { // Test if the two series has the same size if (series1 != null && series2 != null) { DicomImageElement image1 = series1.getMedia(MEDIA_POSITION.MIDDLE, null, null); DicomImageElement image2 = series2.getMedia(MEDIA_POSITION.MIDDLE, null, null); if (image1 != null && image2 != null) { return image1.hasSameSize(image2); } } return false; }
public SeriesThumbnail(final MediaSeries<? extends MediaElement> sequence, int thumbnailSize) { super(thumbnailSize); if (sequence == null) { throw new IllegalArgumentException("Sequence cannot be null"); //$NON-NLS-1$ } this.series = sequence; // media can be null for seriesThumbnail MediaElement media = sequence.getMedia(MEDIA_POSITION.MIDDLE, null, null); // Handle special case for DICOM SR if (media == null) { List<MediaElement> specialElements = (List<MediaElement>) series.getTagValue(TagW.DicomSpecialElementList); if (specialElements != null && !specialElements.isEmpty()) { media = specialElements.get(0); } } /* * Do not remove the image from the cache after building the thumbnail when the series is associated to a * explorerModel (stream should be closed at least when closing the application or when free the cache). */ init(media, series.getTagValue(TagW.ExplorerModel) != null, null); }
public synchronized void setThumbnailSize(int thumbnailSize) { boolean update = this.thumbnailSize != thumbnailSize; if (update) { Object media = series.getMedia(mediaPosition, null, null); this.thumbnailSize = thumbnailSize; removeImageFromCache(); buildThumbnail((MediaElement) media, series.getTagValue(TagW.ExplorerModel) != null, null); } }
public synchronized void reBuildThumbnail(File file, MediaSeries.MEDIA_POSITION position) { MediaElement media = series.getMedia(position, null, null); // Handle special case for DICOM SR if (media == null) { List<MediaElement> specialElements = (List<MediaElement>) series.getTagValue(TagW.DicomSpecialElementList); if (specialElements != null && !specialElements.isEmpty()) { media = specialElements.get(0); } } if (file != null || media != null) { mediaPosition = position; if (thumbnailPath != null && thumbnailPath.getPath().startsWith(AppProperties.FILE_CACHE_DIR.getPath())) { FileUtil.delete(thumbnailPath); // delete old temp file } thumbnailPath = file; readable = true; /* * Do not remove the image from the cache after building the thumbnail when the series is associated to a * explorerModel (stream should be closed at least when closing the application or when free the cache). */ buildThumbnail(media, series.getTagValue(TagW.ExplorerModel) != null, null); revalidate(); repaint(); } }
private void getThickness(final JSliderW sliderThickness) { StringBuilder buf = new StringBuilder(MipView.MIP_THICKNESS.getTitle()); buf.append(StringUtil.COLON_AND_SPACE); int val = sliderThickness.getValue(); buf.append(val); MediaSeries<DicomImageElement> series = view.getSeries(); if (series != null) { int slice = frameSlider.getValue() - 1; SeriesComparator sort = (SeriesComparator) view.getActionValue(ActionW.SORTSTACK.cmd()); Boolean reverse = (Boolean) view.getActionValue(ActionW.INVERSESTACK.cmd()); Comparator sortFilter = (reverse != null && reverse) ? sort.getReversOrderComparator() : sort; Filter filter = (Filter) view.getActionValue(ActionW.FILTERED_SERIES.cmd()); int min = Math.max(0, slice - val); int max = Math.min(series.size(filter) - 1, slice + val); DicomImageElement fimg = series.getMedia(min, filter, sortFilter); DicomImageElement limg = series.getMedia(max, filter, sortFilter); if (fimg != null && limg != null) { buf.append(" ("); //$NON-NLS-1$ buf.append(DecFormater.oneDecimal(SeriesBuilder.getThickness(fimg, limg))); buf.append(" "); //$NON-NLS-1$ buf.append(fimg.getPixelSpacingUnit().getAbbreviation()); buf.append(")"); //$NON-NLS-1$ } } updateSliderProoperties(sliderThickness, buf.toString()); }
if (tileOffset != 0) { imgElement = series.getMedia(value.getSeriesIndex() + tileOffset, (Filter<E>) actionsInView.get(ActionW.FILTERED_SERIES.cmd()), getCurrentSortComparator()); } else if (value.getMedia() instanceof ImageElement) { imgElement = series.getMedia(value.getSeriesIndex() + tileOffset, (Filter<E>) actionsInView.get(ActionW.FILTERED_SERIES.cmd()), getCurrentSortComparator());
public SliceOrientation getSliceOrientation() { SliceOrientation sliceOrientation = null; MediaSeries<DicomImageElement> s = getSeries(); if (s != null) { Object img = s.getMedia(MediaSeries.MEDIA_POSITION.MIDDLE, null, null); if (img instanceof DicomImageElement) { double[] v = TagD.getTagValue((DicomImageElement) img, Tag.ImageOrientationPatient, double[].class); if (v != null && v.length == 6) { Label orientation = ImageOrientation.makeImageOrientationLabelFromImageOrientationPatient(v[0], v[1], v[2], v[3], v[4], v[5]); if (ImageOrientation.Label.AXIAL.equals(orientation)) { sliceOrientation = SliceOrientation.AXIAL; } else if (ImageOrientation.Label.CORONAL.equals(orientation)) { sliceOrientation = SliceOrientation.CORONAL; } else if (ImageOrientation.Label.SAGITTAL.equals(orientation)) { sliceOrientation = SliceOrientation.SAGITTAL; } } } } return sliceOrientation; }
public MprView selectLayoutPositionForAddingSeries(MediaSeries<DicomImageElement> s) { if (s != null) { Object img = s.getMedia(MediaSeries.MEDIA_POSITION.MIDDLE, null, null); if (img instanceof DicomImageElement) { double[] v = TagD.getTagValue((DicomImageElement) img, Tag.ImageOrientationPatient, double[].class); if (v != null && v.length == 6) { Label orientation = ImageOrientation.makeImageOrientationLabelFromImageOrientationPatient(v[0], v[1], v[2], v[3], v[4], v[5]); SliceOrientation sliceOrientation = SliceOrientation.AXIAL; if (ImageOrientation.Label.CORONAL.equals(orientation)) { sliceOrientation = SliceOrientation.CORONAL; } else if (ImageOrientation.Label.SAGITTAL.equals(orientation)) { sliceOrientation = SliceOrientation.SAGITTAL; } MprView view = getMprView(sliceOrientation); if (view != null) { setSelectedImagePane(view); return view; } } } } return null; }
E media = selectedMedia; if (selectedMedia == null) { media = newSeries.getMedia(tileOffset < 0 ? 0 : tileOffset, (Filter<E>) actionsInView.get(ActionW.FILTERED_SERIES.cmd()), getCurrentSortComparator());
DicomImageElement img = series.getMedia(MediaSeries.MEDIA_POSITION.MIDDLE, filter, sortFilter); final Attributes attributes = ((DcmMediaReader) img.getMediaReader()).getDicomObject(); final int[] COPIED_ATTRS = { Tag.SpecificCharacterSet, Tag.PatientID, Tag.PatientName, Tag.PatientBirthDate,
private static void updateImage(ViewCanvas<DicomImageElement> view2D, Filter<DicomImageElement> sopInstanceUIDFilter, int newImageIndex) { int imgIndex = newImageIndex < 0 ? 0 : newImageIndex; if (view2D == view2D.getEventManager().getSelectedViewPane()) { /* * Update the sliceAction action according to nearest image when the filter hides the image of the previous * state. And update the action min and max. */ ActionState seqAction = view2D.getEventManager().getAction(ActionW.SCROLL_SERIES); if (seqAction instanceof SliderCineListener) { SliderChangeListener moveTroughSliceAction = (SliderChangeListener) seqAction; moveTroughSliceAction.setSliderMinMaxValue(1, view2D.getSeries().size(sopInstanceUIDFilter), imgIndex + 1); } } DicomImageElement newImage = null; if (view2D.getSeries() != null) { newImage = view2D.getSeries().getMedia(imgIndex, sopInstanceUIDFilter, view2D.getCurrentSortComparator()); } if (newImage != null && !newImage.isImageAvailable()) { newImage.getImage(); } ((View2d) view2D).setImage(newImage); } }
DicomImageElement img = series.getMedia(MEDIA_POSITION.MIDDLE, null, null); double[] val = img == null ? null : (double[]) img.getTagValue(TagW.SlicePosition);
? series.getMedia(MediaSeries.MEDIA_POSITION.FIRST, filter, SortSeriesStack.slicePosition) : series.getMedia(MediaSeries.MEDIA_POSITION.LAST, filter, SortSeriesStack.slicePosition); if (img != null && img.getMediaReader() instanceof DcmMediaReader) { GeometryOfSlice geometry = img.getDispSliceGeometry(); img = series.getMedia(MediaSeries.MEDIA_POSITION.MIDDLE, filter, SortSeriesStack.slicePosition); final Attributes attributes = ((DcmMediaReader) img.getMediaReader()).getDicomObject();