Skip to content

Commit

Permalink
Merge pull request #35 from logicvay2010/isonet
Browse files Browse the repository at this point in the history
Fix new issues
  • Loading branch information
logicvay2010 authored Sep 10, 2024
2 parents 4f18cfe + 0094b4a commit 51341ca
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
6 changes: 3 additions & 3 deletions bin/mask_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from TomoNet.util.io import log
from TomoNet.util.searchParam import SearchParam

def make_mask_one(tomo_path, mask_name, mask_boundary = None, side = 5, density_percentage=50.0, std_percentage=50.0, surface=None):
def make_mask_one(tomo_path, mask_name, mask_boundary = None, side = 5, density_percentage=50.0, std_percentage=50.0, surface=None, logger=None):

with mrcfile.open(tomo_path, permissive=True) as n:
header_input = n.header
Expand All @@ -33,7 +33,7 @@ def make_mask_one(tomo_path, mask_name, mask_boundary = None, side = 5, density_

if mask_boundary is not None:
from TomoNet.util.filter import boundary_mask
mask3 = boundary_mask(bintomo, mask_boundary, logger=self.logger)
mask3 = boundary_mask(bintomo, mask_boundary, logger=logger)
out_mask_bin = np.multiply(out_mask_bin, mask3)

if (surface is not None) and surface < 1:
Expand Down Expand Up @@ -92,6 +92,6 @@ def make_mask_one(tomo_path, mask_name, mask_boundary = None, side = 5, density_

make_mask_one(mask_params.tomo_file, mask_params.mask_out_name, mask_params.mask_boundary,
mask_params.side, mask_params.density_percentage,
mask_params.std_percentage, mask_params.surface)
mask_params.std_percentage, mask_params.surface, logger=logger)

log(logger, 'time consumed: {:10.4f} s'.format(time.time()-t1))
22 changes: 12 additions & 10 deletions process/bash_expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@ def run(self):
#subprocess.check_output(cmd, shell=True)

self.p = QProcess()

self.p.start(cmd)
res = self.p.waitForFinished(86400)

try:
if cmd.split()[4] == '0':
self.logger.info("Finish generating a new final folder for {}".format(cmd.split()[3]))
else:
self.logger.info("Finish expand {} for {} rounds".format(cmd.split()[3],cmd.split()[4]))
except:
pass
res = self.p.waitForFinished(8.64e7)

if res:
try:
if cmd.split()[4] == '0':
self.logger.info("Finish generating a new final folder for {}".format(cmd.split()[3]))
else:
self.logger.info("Finish expand {} for {} rounds".format(cmd.split()[3],cmd.split()[4]))
except:
pass
else:
self.logger.error("Expand failed for {}".format(cmd.split()[3]))
try:
self.kill_process()
except:
Expand Down
2 changes: 1 addition & 1 deletion process/bash_isonet_deconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def run(self):
self.logger.info("Running deconv command: {}".format(cmd))
self.p = QProcess()
self.p.start(cmd)
res = self.p.waitForFinished(86400)
res = self.p.waitForFinished(60000*30)
# deconv_one(it.rlnMicrographName, deconv_tomo_name, self.isonet_folder, voltage=self.voltage, cs=self.cs, defocus=it.rlnDefocus/10000.0, \
# pixel_size=it.rlnPixelSize, snrfalloff=it.rlnSnrFalloff, deconvstrength=it.rlnDeconvStrength, \
# highpassnyquist=self.highpassnyquist, chunk_size=self.chunk_size, overlap_rate=self.overlap_rate, ncpu=self.ncpu, logger=self.logger)
Expand Down
2 changes: 1 addition & 1 deletion process/bash_isonet_generate_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def run(self):
self.logger.info("Running mask generation command: {}".format(cmd))
self.p = QProcess()
self.p.start(cmd)
res = self.p.waitForFinished(86400)
res = self.p.waitForFinished(60000*30)

try:
self.p.terminate()
Expand Down
2 changes: 1 addition & 1 deletion process/bash_isonet_predict_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def run(self):
self.p = QProcess()

self.p.start(self.cmd)
res = self.p.waitForFinished(86400)
res = self.p.waitForFinished(8.64e7)
#self.p.finished.connect(self.kill_process)

def stop_process(self):
Expand Down
2 changes: 1 addition & 1 deletion process/bash_isonet_train_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def run(self):
self.p = QProcess()

self.p.start(self.cmd)
res = self.p.waitForFinished(86400)
res = self.p.waitForFinished(8.64e7*3)
#self.p.finished.connect(self.kill_process)

def stop_process(self):
Expand Down
2 changes: 1 addition & 1 deletion process/bash_predict_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def run(self):
self.p = QProcess()
self.p.start(cmd)
#self.logger.info("PID {}".format(self.p.pid()))
res = self.p.waitForFinished(86400)
res = self.p.waitForFinished(8.64e7)

try:
self.p.terminate()
Expand Down
4 changes: 2 additions & 2 deletions process/bash_train_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ def run(self):
self.p = QProcess()
self.p.start(cmd)
#self.logger.info("PID {}".format(self.p.pid()))
res = self.p.waitForFinished(86400)
res = self.p.waitForFinished(8.64e7*3)
#subprocess.run(cmd, shell=True, encoding="utf-8", stdout=subprocess.PIPE)

# with open("{}/train_params.json".format(self.d['result_folder_train']), 'w') as fp:
# json.dump(self.d, fp, indent=2, default=int)

#clean process
try:
self.p.terminate()
self.p.terminate(8.64e7*3)
#self.p.close()
except:
pass
Expand Down

0 comments on commit 51341ca

Please sign in to comment.