def combine_subtom(out_dir,pickle_path): subvols_loc = os.path.join(out_dir,'selected_demo_single_particle_subvolumes.pickle') pickle_data = AIF.pickle_load(pickle_path) d = AIF.pickle_load(subvols_loc) subvols = [] for v in d['vs'].values(): if v['v'] is not None: subvols.append(v['v']) subtom = pickle_data['1KP8_data'] + pickle_data['1KP8_data'] +subvols[:100] print('Total subtomograms: ',len(subtom)) subvols_loc = os.path.join(out_dir,'subvolumes.pickle') d = {} d['v_siz'] = np.array([32,32,32]) d['vs'] = {} labels = {} for i in range(len(subtom)): uuid_i = str(uuid.uuid4()) d['vs'][uuid_i] = {} d['vs'][uuid_i]['center'] = None d['vs'][uuid_i]['id'] = uuid_i d['vs'][uuid_i]['v'] = subtom[i] d['vs'][uuid_i]['label'] = int(i/100) AIF.pickle_dump(d, subvols_loc) print("Save subvolumes .pickle file to:", subvols_loc)
def kmeans_centers_plot(clus_center_dir): kmeans_clus = AIF.pickle_load(op_join(clus_center_dir, 'kmeans.pickle')) ccents = AIF.pickle_load(op_join(clus_center_dir, 'ccents.pickle')) # export slices for visual inspection if False: for i in ccents: auto.dsp_cub(ccents[i]) else: clus_center_figure_dir = op_join(clus_center_dir, 'fig') if os.path.isdir(clus_center_figure_dir): shutil.rmtree(clus_center_figure_dir) os.makedirs(clus_center_figure_dir) # normalize across all images min_t = N.min([ccents[_].min() for _ in ccents]) max_t = N.max([ccents[_].max() for _ in ccents]) assert max_t > min_t ccents_t = {_: ((ccents[_] - min_t) / (max_t - min_t)) for _ in ccents} ccents_t = ccents for i in ccents_t: clus_siz = len(kmeans_clus[i]) t = AIVU.cub_img(ccents_t[i])['im'] AIIO.save_png(t, op_join(clus_center_figure_dir, '%003d--%d.png' % (i, clus_siz)), normalize=False)
def view_subtom(self,subvol_num,sigma=2,R=10): subvols_loc = os.path.join(self.dump_path,"demo_single_particle_subvolumes.pickle") d = io_file.pickle_load(subvols_loc) a = io_file.read_mrc_data(self.path) # denoise a_smooth = smooth(a,sigma) if 'self.centers' not in dir(): centers = [] uuids = [] for k,v in d['vs'].items(): if v['v'] is not None: centers.append(v['center']) uuids.append(k) self.centers = centers self.uuids = uuids y, x, z = self.centers[subvol_num] img = a_smooth[:,:,z] plt.rcParams['figure.figsize'] = (10.0, 8.0) fig = plt.figure() ax = fig.add_subplot(111) circle = plt.Circle((x, y), R, color='b', fill=False) plt.gcf().gca().add_artist(circle) plt.axis('off') output_str = '%d of %d, uuid = %s' % ( subvol_num, len(centers), self.uuids[subvol_num]) plt.title(output_str) ax_u = ax.imshow(img, cmap = 'gray') save_path = 'tmp_sub.png' # plt.imsave(save_path, img, cmap='gray') plt.savefig(save_path) return save_path
def view_tomo(self,sigma=2,R=10): # d = {v_siz:(32,32,32), vs:{uuid0:{center, v, id}, uuid1:{center, v, id} ... }} subvols_loc = os.path.join(self.dump_path,"demo_single_particle_subvolumes.pickle") d = io_file.pickle_load(subvols_loc) a = io_file.read_mrc_data(self.path) if 'self.centers' not in dir(): centers = [] uuids = [] for k,v in d['vs'].items(): if v['v'] is not None: centers.append(v['center']) uuids.append(k) self.centers = centers self.uuids = uuids # denoise a_smooth = smooth(a,sigma) for slice_num in range(a_smooth.shape[2]): centers = np.array(centers) slice_centers = centers[(centers[:,2]-slice_num)**2<R**2] img = a_smooth[:,:,slice_num] plt.rcParams['figure.figsize'] = (15.0, 12.0) fig = plt.figure() ax = fig.add_subplot(111) plt.axis('off') for center_num in range(len(slice_centers)): y, x = slice_centers[center_num][0:2] r = np.sqrt(R**2 - (slice_centers[center_num][2]-slice_num)**2) circle = plt.Circle((x, y), r, color='b', fill=False) plt.gcf().gca().add_artist(circle) ax_u = ax.imshow(img, cmap = 'gray')
def load_dict(path): if not os.path.isfile(path): d = {} AIF.pickle_dump(d, path) else: d = AIF.pickle_load(path) return d
def autoencoder_single_main(request: AESingleRequest): item = particlePickingPool.get(request.path) remove_particles = list(map(int, request.remove_particles.replace(',', ' ').split())) pick_num = 100 item.pick.select(remove_particles, pick_num) subvols_loc = os.path.join( item.dump_folder, "selected_demo_single_particle_subvolumes.pickle") output_dir = os.path.join(item.dump_folder, 'autoencoder_particle') d = AIF.pickle_load(subvols_loc) AE.encoder_simple_conv_test(d=d, pose=None, img_org_file=False, out_dir=output_dir, clus_num=1) AE.kmeans_centers_plot(AE.op_join(output_dir, 'clus-center')) return AESingleResponse()
def select(self,remove_particles,pick_num): d = io_file.pickle_load(os.path.join(self.dump_path,"demo_single_particle_subvolumes.pickle")) subvols_loc = os.path.join(self.dump_path,"selected_demo_single_particle_subvolumes.pickle") particles_num = pick_num result = {} result['v_siz'] = d['v_siz'] result['vs'] = {} remove_particles = np.array(remove_particles) # d = {v_siz:(32,32,32), vs:{uuid0:{center, v, id}, uuid1:{center, v, id} ... }} for i in range(len(self.centers)): if i in remove_particles: continue uuid_i = self.uuids[i] result['vs'][uuid_i] = d['vs'][uuid_i] if len(result['vs']) >= particles_num: break assert len(result['vs']) == particles_num # subvols_loc = './tmp/picking/selected_demo_single_particle_subvolumes.pickle' AIF.pickle_dump(result, subvols_loc) print("Save subvolumes .pickle file to:", subvols_loc)
def EM(img_data, K, iteration, path, snapshot_interval=5, reg=False, use_voronoi=True): """ The main estimation-maximization algorithm """ np.seterr(all='ignore') X = get_image_db(img_data['db_path']) dj = img_data['dj'] N = len(dj) n_x, n_y, n_z = X[dj[0]['v']].shape theta = dict() theta['N'] = N theta['J'] = n_x * n_y * n_z theta['n'] = n_x theta['K'] = K # Proportional to the radius of the image theta['xi'] = theta['n'] # We need to initialize this later theta['A'] = np.zeros([K, n_x, n_y, n_z], dtype=np.complex128) theta['alpha'] = np.ones([K], dtype=np.float_) / K theta['trans_list'] = None theta['predictions'] = np.zeros([N]) # Print relavent information print("Running model based alignment: N=%d, K=%d, dimensions=(%d,%d,%d)" % (N, K, n_x, n_y, n_z)) if reg: print("With regularization") else: print("Without regularization") if use_voronoi: print("With voronoi weights") else: print("Without voronoi weights") # Regularization reg_step = (float(N) / K**2) / 2 theta['theta_reg'] = 5 * reg_step if reg else 0 # Sample K random data points from the set to initialize A indices = np.random.permutation(N) num_models = [0 for _ in range(K)] k = 0 for i in range(N): theta['A'][k] += X[dj[indices[i]]['v']] * X[dj[indices[i]]['m']] num_models[k] += 1 k = (k + 1) % K for k in range(K): theta['A'][k] /= num_models[k] # Get a random A_k and a random X_i and calculate sum_j to get sigma_sq k = np.random.randint(K) i = np.random.randint(N) sum_j = np.sum( np.square(np.absolute(theta['A'][k] - X[dj[i]['v']]) * X[dj[i]['m']])) theta['sigma_sq'] = sum_j / theta['J'] print("Sigma_sq initialized to %d" % theta['sigma_sq']) checkpoint_dir = os.path.join(path, 'checkpoints') if not os.path.exists(checkpoint_dir): os.makedirs(checkpoint_dir) interval = snapshot_interval for i in range(iteration): checkpoint_file = os.path.join(checkpoint_dir, '%08d.pickle' % i) if os.path.exists(checkpoint_file): checkpoint_data = AIF.pickle_load(checkpoint_file) theta = checkpoint_data['theta'] continue if i % interval == 0: output_images(theta, i, path=path) print("Running iteration %d" % (i + 1)) # Update alpha before updating A compute_trans_list(theta=theta, img_data=img_data, use_voronoi=use_voronoi) alpha = update_alpha(img_data=img_data, theta=theta, use_voronoi=use_voronoi) print("Alpha updated! Alpha = ", end=' ') print(alpha.tolist()) sigma_sq = update_sigma(img_data=img_data, theta=theta, reg=reg, use_voronoi=use_voronoi) print("Sigma updated! Sigma^2 = ", end=' ') print(sigma_sq) xi = update_xi(img_data=img_data, theta=theta, use_voronoi=use_voronoi) print("Xi updated! Xi = ", end=' ') print(xi) A = update_a(img_data=img_data, theta=theta, alpha=alpha, reg=reg, use_voronoi=use_voronoi) print("A updated! Average intensity of A = ", end=' ') print(np.average(A, (1, 2, 3))) theta['alpha'] = alpha theta['sigma_sq'] = sigma_sq theta['xi'] = xi theta['A'] = A # Since we changed the models A, the list of optimal transforms # needs to be re-calculated theta['trans_list'] = None theta['pred'] = None # Decrease the regularization coefficient if reg and theta['theta_reg'] > 0: theta['theta_reg'] -= reg_step theta['theta_reg'] = max(0, theta['theta_reg']) try: assert not os.path.exists(checkpoint_file) except: raise Exception("Checkpoint file already exists!") AIF.pickle_dump({'theta': theta}, checkpoint_file) print_prediction_results(theta, img_data) output_images(theta, iteration, path=path) print("Prediction from model: ", end=' ') print(theta['predictions']) return theta
def main(args): ''' Step1:Prepare input dataset You can download the example dataset from https://cmu.app.box.com/s/9hn3qqtqmivauus3kgtasg5uzlj53wxp/file/509296892992 into your present working directory. Note: This is not the dataset used in the paper, which will be added in the future. Here's four parameters and dataset format. 1.A python pickle data file of CECT small subvolumes, this data file should be prepared as follows: d is the small subvolume data file. d is a dictionary consists 'v_siz' and 'vs'. d['v_siz'] is an numpy.ndarray specifying the shape of the small subvolume. For example, d['v_siz'] = array([32,32,32]). d['vs'] is a dictionary with keys of uuids specifying each small subvolume. d['vs'][an example uuid] is a dictionary consists 'center', 'id', and 'v'. d['vs'][an example uuid]['center'] is the center of the small subvolume in the tomogram. For example, d['vs'][an example uuid]['center'] = [110,407,200]. d['vs'][an example uuid]['id'] is the specific uuid. d['vs'][an example uuid]['v'] are voxel values of the small subvolume, which is an numpy.ndarray of shape d['v_siz']. 2.A tomogram file in .rec format, which is only required when performing pose normalization. 3.Whether the optional pose normalization step should be applied. Input should be True or False. 4.The number of clusters. This should be an positive integer such as 100. ''' ''' Step2 Train the auto encoder. Given the example dataset, you can use parameters1 or parameters2. ''' import aitom.classify.deep.unsupervised.autoencoder.autoencoder as AE import time s_time = time.time() # Note: these two datasets are missing for now # parameters1 = ["example/subvolumes_example_2.pickle", "None", "False", "4"] # parameters2 = ["example/subvolumes_example_1.pickle", "example/tomogram.rec", "True", "100"] # This example dataset is generated in the particle picking tutorial single_particle_param = [ 'data/demo_single_particle_subvolumes.pickle', 'None', "False", 4 ] out_dir = args.output_dir if args.data: single_particle_param[0] = args.data if args.cluster_number: single_particle_param[3] = args.cluster_number # demo dataset format is different, which has 2 kinds of particle and their templates multiple_particles_params = [ 'data/aitom_demo_subtomograms.pickle', 'None', "False", 4 ] parameters_demo = single_particle_param # choose one of the above import aitom.io.file as AIF d = AIF.pickle_load( parameters_demo[0]) # pickle data file of CECT small subvolumes if parameters_demo == multiple_particles_params: # TODO add multiparticle tutorial # choose one particle and convert the data format # d = d['5T2C_data'] # from aitom.classify.deep.unsupervised.autoencoder.autoencoder_util import subtomograms_to_subvolumes # d = subtomograms_to_subvolumes(d) pass img_org_file = parameters_demo[ 1] #A tomogram file in .rec format, which can be None when pose normalization is not required pose = eval( parameters_demo[2] ) #Whether the optional pose normalization step should be applied True or False clus_num = int(parameters_demo[3]) # The number of clusters AE.encoder_simple_conv_test(d=d, pose=pose, img_org_file=img_org_file, out_dir=out_dir, clus_num=clus_num) AE.kmeans_centers_plot(AE.op_join(out_dir, 'clus-center')) ''' Step 3. Manual selection of small subvolume clusters Autoencoder3D training step will have two output folders. 'model' directory saved the trained models 'clus-center' directory for the resulting clusters. There should be two pickle files in 'clus-center'. 'kmeans.pickle' stores the uuids for each cluster. 'ccents.pickle' stores the decoded cluster centers. The 'fig' folder under 'clus-center' directory contains the 2D slices of decoded cluster center. User can use the figures as guide for manual selection. Manual selection clues are provided in the folder 'fig' under 'clus-center'. Each picture is a 2D slices presentation of a decoded small subvolume cluster center. The picture name such as '035--47.png' refers to cluster 35 which consists 47 small subvolumes. ''' ''' Step 4. Optional Encoder-decoder Semantic Segmentation 3D network training. Based on the manual selection results, Encoder-decoder Semantic Segmentation 3D (EDSS3D) network can be trained and applied for another tomogram dataset. ''' import aitom.classify.deep.unsupervised.autoencoder.seg_src as SEG import os from os.path import join as op_join # sel_clus = {1: [3, 21, 28, 34, 38, 39, 43, 62, 63, 81, 86, 88], # 2: [15, 25, 29, 33, 35, 66, 79, 90, 92, 98]} # an example of selected clusters for segmentation # sel_clus is the selected clusters for segmentation, which can be multiple classes. sel_clus = {0: [3, 21, 28, 34, 38, 39, 43, 62, 63, 81, 86, 88]} import numpy as np # sel_clus = {0: np.arange(100)} data_dir = out_dir data_file = op_join( data_dir, parameters_demo[0] ) #here's the name of pickle data file of CECT small subvolumes with open(data_file, 'rb') as f: d = SEG.pickle.load(f, encoding='iso-8859-1') SEG.decode_all_images(d, data_dir) # The following files come from the previous Autoencoder3D results with open(op_join(data_dir, 'clus-center', 'kmeans.pickle'), 'rb') as f: km = SEG.pickle.load(f, encoding='iso-8859-1') with open(op_join(data_dir, 'clus-center', 'ccents.pickle'), 'rb') as f: cc = SEG.pickle.load(f, encoding='iso-8859-1') with open(op_join(data_dir, 'decoded', 'decoded.pickle'), 'rb') as f: vs_dec = SEG.pickle.load(f, encoding='iso-8859-1') print('sel_clus', len(sel_clus)) print('km', len(km)) vs_lbl = SEG.image_label_prepare(sel_clus, km) print('vs_lbl', len(vs_lbl)) # print(vs_lbl) for key in vs_lbl: vs_lbl[key] = 1 print('vs_lbl', len(vs_lbl)) # print(vs_lbl) vs_seg = SEG.train_label_prepare( vs_lbl=vs_lbl, vs_dec=vs_dec, iso_value=0.5) # iso_value is the mask threshold for segmentation print('vs_seg', len(vs_seg)) model_dir = op_join(data_dir, 'model-seg') if not os.path.isdir(model_dir): os.makedirs(model_dir) model_checkpoint_file = op_join(model_dir, 'model-seg--weights--best.h5') model_file = op_join(model_dir, 'model-seg.h5') if os.path.isfile(model_file): print('use existing', model_file) import keras.models as KM model = KM.load_model(model_file) else: model = SEG.train_validate__reshape( vs_lbl=vs_lbl, vs=d['vs'], vs_seg=vs_seg, model_file=model_file, model_checkpoint_file=model_checkpoint_file) model.save(model_file) # Segmentation prediction on new data data_dir = out_dir # This should be the new data for prediction data_file = op_join(data_dir, parameters_demo[0]) with open(data_file, 'rb') as f: d = SEG.pickle.load(f, encoding='iso-8859-1') prediction_dir = op_join(data_dir, 'prediction') if not os.path.isdir(prediction_dir): os.makedirs(prediction_dir) vs_p = SEG.predict__reshape(model, vs={_: d['vs'][_]['v'] for _ in vs_seg}) with open(op_join(prediction_dir, 'vs_p.pickle'), 'wb') as f: SEG.pickle.dump(vs_p, f, protocol=-1) print(time.time() - s_time, 's')
shuffle=True, sample_weight={ 'dense_4': masks, 'sequential_1': masks_auto_training }, validation_data=(data_validation, [data_validation, labels_validation]), callbacks=[checkpoint, earlyStopping]) else: model = auto_classifier_model(img_shape=x_train[0].shape, num_of_class=num_of_class) model.load_weights(model_autoclassifier_checkpoint_file) x_rec, classification_testing = model.predict([x_test]) test_prediction = np.argmax(classification_testing, axis=1) test_real_class = np.argmax(test_labels, axis=1) true = 0. all_sample = float(len(test_prediction)) for i in range(len(test_prediction)): if test_prediction[i] == test_real_class[i]: true += 1. testing_accuracy = true / all_sample print("Classification Accuracy: %f" % testing_accuracy) mse_error = mean_squared_error(x_rec.flatten(), x_test.flatten()) print("Reconstruction Error: %f" % mse_error) if __name__ == "__main__": d = AIF.pickle_load(sys.argv[1]) option = sys.argv[2] run_auto_classifier(d=d, option=option, out_dir=os.getcwd())
op['data_checkpoint'] = os.path.join(out_dir, 'djs.pickle') op['dim_reduction'] = {} op['dim_reduction']['pca'] = { 'n_dims': 50, 'n_iter': 10, 'checkpoint': os.path.join(out_dir, 'pca.pickle') } op['clustering'] = { 'kmeans_k': class_num, 'checkpoint': os.path.join(out_dir, 'clustering.pickle') } op['average'] = {} op['average']['mask_count_threshold'] = 2 op['average']['checkpoint'] = os.path.join(out_dir, 'avgs.pickle') dj = AIF.pickle_load(os.path.join(test_dir, 'data.pickle')) img_db = TIDL.LSM(os.path.join(test_dir, 'image.db'), readonly=True) randomize_orientation(dj) clas.classify(dj_init=dj, img_db=img_db, op=op) export_avgs(AIF.pickle_load(os.path.join(out_dir, 'avgs.pickle')), out_dir=os.path.join(out_dir, 'avgs-export')) print('classification complete') else: # averaging only import aitom.average.align.simple_iterative.average as avg op = {} op['option'] = {'pass_num': 20} # the number of iterations op['data_checkpoint'] = os.path.join(out_dir, 'djs.pickle') op['average'] = {} op['average']['mask_count_threshold'] = 2
def single_average(subtom): print('subtom_type=', type(subtom)) assert len(subtom) == 100 print('subtom[0]_type=', type(subtom[0])) average = True test_dir = './tmp/cls-test/' + str(uuid.uuid4()) # test dir if os.path.exists(test_dir): shutil.rmtree(test_dir) os.makedirs(test_dir) dj_file = os.path.join(test_dir, 'data.pickle') img_db_file = os.path.join(test_dir, 'image.db') v_num = 100 # the number of each class v_dim_siz = 32 wedge_angle = 30 mask_id = str(uuid.uuid4()) dj = [] class_num = 1 for model_id in range(class_num): for v_i in range(v_num): ang_t = [_ for _ in N.random.random(3) * (N.pi * 2)] # loc_t = TGA.random_translation(size=[v_dim_siz]*3, proportion=0.2) loc_t = [0.0, 0.0, 0.0] v_id = str(uuid.uuid4()) dj.append({ 'subtomogram': v_id, 'mask': mask_id, 'angle': ang_t, 'loc': loc_t, 'model_id': model_id }) AIF.pickle_dump(dj, dj_file) sim_op = { 'model': { 'missing_wedge_angle': wedge_angle, 'titlt_angle_step': 1, 'SNR': 1000, 'band_pass_filter': False, 'use_proj_mask': False }, 'ctf': { 'pix_size': 1.0, 'Dz': -5.0, 'voltage': 300, 'Cs': 2.0, 'sigma': 0.4 } } img_db = TIDL.LSM(img_db_file) index = 0 for d in dj: img_db[d['subtomogram']] = subtom[index].astype(N.float) # print(img_db[d['subtomogram']].shape) index = index + 1 import aitom.image.vol.wedge.util as TIVWU img_db[mask_id] = TIVWU.wedge_mask(size=[v_dim_siz] * 3, ang1=wedge_angle) print('file generation complete') out_dir = os.path.join(test_dir, 'out') if os.path.exists(out_dir): shutil.rmtree(out_dir) os.makedirs(out_dir) from aitom.classify.align.simple_iterative.classify import randomize_orientation from aitom.classify.align.simple_iterative.classify import export_avgs if average: import aitom.average.align.simple_iterative.average as avg op = {} op['option'] = {'pass_num': 20} # the number of iterations op['data_checkpoint'] = os.path.join(out_dir, 'djs.pickle') op['average'] = {} op['average']['mask_count_threshold'] = 2 op['average']['checkpoint'] = os.path.join(out_dir, 'avgs.pickle') dj = AIF.pickle_load(os.path.join(test_dir, 'data.pickle')) img_db = TIDL.LSM(os.path.join(test_dir, 'image.db'), readonly=True) randomize_orientation(dj) avg.average(dj_init=dj, img_db=img_db, op=op) export_avgs(AIF.pickle_load(os.path.join(out_dir, 'avgs.pickle')), out_dir=os.path.join(out_dir, 'avgs-export')) print('averaging done') # visualization # test_dir = './tmp/cls-test/'+str(uuid.uuid4()) # test dir avgs = pickle_load(os.path.join(test_dir, 'out/avgs.pickle')) out_dir = os.path.join(test_dir, 'image') if os.path.exists(out_dir): shutil.rmtree(out_dir) os.makedirs(out_dir) for i in avgs.keys(): v = avgs[i]['v'] file_name = str(avgs[i]['pass_i']) + '_' + str(i) + '.png' save_png(cub_img(v)['im'], os.path.join(out_dir, file_name)) print('images saved in', out_dir)
/shared/opt/local/img/em/et/util/situs/Situs_2.7.2/bin/pdb2vol /opt/local/img/em/et/util/situs/Situs_2.7.2/bin/pdb2vol spacing_s: is the voxel spacing in Anstron resolution_s: the image resolution in Anstron pdb_dir: the directory that contains pdb files. Could be your own directory or /shared/shared/data/pdb or /shared/data/pdb out_file: the output file that contains converted density maps ''' op = { 'situs_pdb2vol_program': '/shared/opt/local/img/em/et/util/situs/Situs_2.7.2/bin/pdb2vol', 'spacing_s': [10.0], 'resolution_s': [10.0], 'pdb_dir': '/shared/data/pdb', 'out_file': 'situs_maps.pickle' } # convert to density maps, save to situs_maps.pickle import aitom.structure.pdb.situs_pdb2vol__batch as TSPS TSPS.batch_processing(op) ''' The density maps in situs_maps.pickle have different sizes for different structures, use resize_center_batch_dict() to change them into same size ''' import aitom.io.file as TIF ms = TIF.pickle_load('situs_maps.pickle') ms = {_: ms[_][10.0][10.0]['map'] for _ in ms} import aitom.image.vol.util as TIVU ms = TIVU.resize_center_batch_dict(vs=ms, cval=0.0)
# Note: these two datasets are missing for now # parameters1 = ["example/subvolumes_example_2.pickle", "None", "False", "4"] # parameters2 = ["example/subvolumes_example_1.pickle", "example/tomogram.rec", "True", "100"] # This example dataset is generated in the particle picking tutorial single_particle_param = [ 'data/demo_single_particle_subvolumes.pickle', 'None', "False", 4 ] # demo dataset format is different, which has 2 kinds of particle and their templates multiple_particles_params = [ 'data/aitom_demo_subtomograms.pickle', 'None', "False", 4 ] parameters_demo = single_particle_param # choose one of the above import aitom.io.file as AIF d = AIF.pickle_load( parameters_demo[0]) # pickle data file of CECT small subvolumes if parameters_demo == multiple_particles_params: # TODO add multiparticle tutorial # choose one particle and convert the data format # d = d['5T2C_data'] # from aitom.classify.deep.unsupervised.autoencoder.autoencoder_util import subtomograms_to_subvolumes # d = subtomograms_to_subvolumes(d) pass img_org_file = parameters_demo[ 1] #A tomogram file in .rec format, which can be None when pose normalization is not required pose = eval( parameters_demo[2] ) #Whether the optional pose normalization step should be applied True or False clus_num = int(parameters_demo[3]) # The number of clusters