Skip to content

Instantly share code, notes, and snippets.

@cnd
cnd / c.cxx
Created December 18, 2020 12:10
template <typename TPixelType>
void AutoplanExporterDicom::doExport(mitk::Image* image, AutoplanExporter::ExportParams& exportParams, std::vector<boost::filesystem::path>& exportedFolders, const DoExportParams& params)
{
std::vector<itk::MetaDataDictionary*> dicomMetaDataDictionaryArray = params.originalImage->GetMetaDataDictionaryArray();
std::vector<itk::MetaDataDictionary*>* workDictionaryArray = &dicomMetaDataDictionaryArray;
std::unique_ptr<DicomAnonimizer> anonimizer = nullptr;
if (exportParams.m_Anonimize) {
anonimizer.reset(new DicomAnonimizer(dicomMetaDataDictionaryArray));
workDictionaryArray = &anonimizer->getAnonimizedDictionaries();
}
@cnd
cnd / c.py
Created April 29, 2020 18:04
def grad_cam(input_model, model_x, orig_x, category_index, layer_name, class_names):
output = input_model.output
final_layer = Lambda(lambda x: target_category_loss(x, category_index, len(class_names)))
output = final_layer(output)
model = Model(inputs=input_model.input, outputs=output)
loss = K.sum(model.layers[-1].output)
conv_output = model.get_layer(layer_name).output
grads = normalize(K.gradients(loss, conv_output)[0])
gradient_function = K.function([model.layers[0].input, K.learning_phase()], [conv_output, grads])
@cnd
cnd / dicom.py
Created February 28, 2020 12:59
if file.filename.endswith('.jpg') or file.filename.endswith('.png'):
is_dicom = False
img = cv2.imdecode(np.fromstring(file.read(), np.uint8), 1)
else:
is_dicom = True
df = dicom.dcmread(file) # .pixel_array
slope = float(df.RescaleSlope)
intercept = float(df.RescaleIntercept)
df_data = intercept + df.pixel_array * slope / 20
home λ haskell-updater root⋆cloyster ~/ ∅
Running haskell-updater-1.3.1 using GHC 8.6.5
* Executable: /usr/bin/ghc
* Library directory: /usr/lib64/ghc-8.6.5
* Package manager (PM): portage
* Mode: OnlyInvalid
Searching for packages installed with a different version of GHC.
No old packages found!
 * Package: gnome-base/gnome-shell-3.33.3-r1
 * Repository: gnome-next
 * Maintainer: gnome@gentoo.org
 * USE: abi_x86_64 amd64 bluetooth browser-extension elibc_glibc ibus kernel_linux networkmanager python_single_target_python3_7 python_targets_python3_7 systemd userland_GNU
 * FEATURES: ccache preserve-libs sandbox userpriv usersandbox
>>> Unpacking source...
>>> Unpacking gnome-shell-3.33.3.tar.xz to /var/tmp/portage/gnome-base/gnome-shell-3.33.3-r1/work
>>> Source unpacked in /var/tmp/portage/gnome-base/gnome-shell-3.33.3-r1/work
>>> Preparing source in /var/tmp/portage/gnome-base/gnome-shell-3.33.3-r1/work/gnome-shell-3.33.3 ...
* Applying patches from /var/tmp/portage/gnome-base/gnome-shell-3.33.3-r1/files/ ...
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d (Conv2D) (None, 510, 510, 32) 896
_________________________________________________________________
conv2d_1 (Conv2D) (None, 508, 508, 32) 9248
_________________________________________________________________
conv2d_2 (Conv2D) (None, 506, 506, 32) 9248
_________________________________________________________________
Traceback (most recent call last):
File "/usr/lib64/python3.7/site-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/lib64/python3.7/site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/usr/lib64/python3.7/site-packages/flask_restful/__init__.py", line 269, in error_router
return original_handler(e)
File "/usr/lib64/python3.7/site-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib64/python3.7/site-packages/flask/_compat.py", line 35, in reraise
conky.config = {
own_window = true,
own_window_transparent = true,
own_window_type = 'window',
own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
own_window_argb_visual = true,
own_window_argb_value = 0,
out_to_console = false,
use_xft = true,
font = 'Cantarell:size=11',
pub struct SChannel<'s> {
pub channel: Channel<'s>,
}
impl<'i> ::std::ops::Deref for SChannel<'i> {
type Target = Channel<'i>;
fn deref(&self) -> &Channel<'i> { &self.channel }
}
pub struct Sess<'s> {
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> src/commands/owner.rs:15:48
|
15 | let sess = ssh_session.ref_rent(|iref| iref);
| ^^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime #3 defined on the body at 15:41...
--> src/commands/owner.rs:15:41
|
15 | let sess = ssh_session.ref_rent(|iref| iref);